From e4d4260e38378143011b1cc64b371658052024af Mon Sep 17 00:00:00 2001 From: Lukas Brand Date: Wed, 2 Oct 2024 17:16:34 +0200 Subject: [PATCH 1/4] Add: - "--user-property" - "--output-to-file" - "--base64" - "--json-output" - "--show-topics" Deprecate: - "-up", "--userProperty" - "-of", "--outputToFile" - "-b64" - "--jsonOutput" - "--showTopics" --- .../cli/commands/cli/SubscribeCommand.java | 7 +- .../commands/options/SubscribeOptions.java | 166 ++++++- .../shell/ContextSubscribeCommand.java | 8 +- .../mqtt/SubscribeMqtt3PublishCallback.java | 2 +- .../mqtt/SubscribeMqtt5PublishCallback.java | 2 +- .../com/hivemq/cli/utils/LoggerUtils.java | 20 +- .../cli/subscribe/SubscribeDeprecationST.java | 406 ++++++++++++++++++ 7 files changed, 588 insertions(+), 23 deletions(-) create mode 100644 src/systemTest/java/com/hivemq/cli/commands/cli/subscribe/SubscribeDeprecationST.java diff --git a/src/main/java/com/hivemq/cli/commands/cli/SubscribeCommand.java b/src/main/java/com/hivemq/cli/commands/cli/SubscribeCommand.java index 2d0621711..ee28afc4e 100644 --- a/src/main/java/com/hivemq/cli/commands/cli/SubscribeCommand.java +++ b/src/main/java/com/hivemq/cli/commands/cli/SubscribeCommand.java @@ -31,6 +31,8 @@ import picocli.CommandLine; import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; import java.util.concurrent.Callable; @@ -41,6 +43,7 @@ public class SubscribeCommand implements Callable { private static final int IDLE_TIME = 5000; + private final @NotNull List deprecationWarnings = new ArrayList<>(); private final @NotNull MqttClientExecutor mqttClientExecutor; private @Nullable MqttClient subscribeClient; @@ -64,7 +67,7 @@ private void printToSTDOUT(final boolean printToSTDOUT) { private final @NotNull ConnectOptions connectOptions = new ConnectOptions(); @CommandLine.Mixin - private final @NotNull SubscribeOptions subscribeOptions = new SubscribeOptions(); + private final @NotNull SubscribeOptions subscribeOptions = new SubscribeOptions(deprecationWarnings); @CommandLine.Mixin private final @NotNull DebugOptions debugOptions = new DebugOptions(); @@ -90,6 +93,8 @@ public SubscribeCommand(final @NotNull MqttClientExecutor mqttClientExecutor) { Logger.trace("Command {}", this); + LoggerUtils.logDeprecatedOptions(deprecationWarnings); + connectOptions.setDefaultOptions(); connectOptions.logUnusedOptions(); subscribeOptions.setDefaultOptions(); diff --git a/src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java b/src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java index 4c76faa5f..a62d6d5a7 100644 --- a/src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java +++ b/src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java @@ -33,10 +33,17 @@ import java.io.File; import java.io.IOException; import java.util.Arrays; +import java.util.List; import java.util.Objects; public class SubscribeOptions { + @SuppressWarnings({"NotNullFieldNotInitialized", "unused"}) + @CommandLine.Spec + private @NotNull CommandLine.Model.CommandSpec spec; + + private final @NotNull List deprecationWarnings; + @SuppressWarnings({"NotNullFieldNotInitialized", "unused"}) //will be initialized via required @CommandLine.Option(names = {"-t", "--topic"}, required = true, description = "The topics to subscribe to") private @NotNull String @NotNull [] topics; @@ -48,37 +55,164 @@ public class SubscribeOptions { description = "Quality of service for the corresponding topics (default for all: 2)") private @NotNull MqttQos @NotNull [] qos; + private @NotNull Mqtt5UserProperty @Nullable [] userProperties = null; + private boolean userPropertiesFromOption = false; + private boolean userPropertiesFromLegacyOption = false; + @SuppressWarnings("unused") - @CommandLine.Option(names = {"-up", "--userProperty"}, + @CommandLine.Option(names = {"--user-property"}, converter = Mqtt5UserPropertyConverter.class, description = "A user property of the subscribe message") - private @Nullable Mqtt5UserProperty @Nullable [] userProperties; + private void userProperties(final @NotNull Mqtt5UserProperty @NotNull [] userProperties) { + if (userPropertiesFromLegacyOption) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the user properties legacy options \"-up\" or \"--userProperty\" and the current \"--user-property\" is used. Please only use \"--user-property\" as the legacy options will be removed in a future version."); + } + userPropertiesFromOption = true; + this.userProperties = userProperties; + } @SuppressWarnings("unused") - @CommandLine.Option(names = {"-of", "--outputToFile"}, + @Deprecated(since = "4.34.0", forRemoval = true) + @CommandLine.Option(names = {"-up", "--userProperty"}, + hidden = true, + converter = Mqtt5UserPropertyConverter.class, + description = "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". They will be removed in a future version.") + private void userPropertiesLegacy(final @NotNull Mqtt5UserProperty @NotNull [] userPropertiesLegacy) { + //only show message once as this method is executed multiple times + if (!userPropertiesFromLegacyOption) { + deprecationWarnings.add( + "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". They will be removed in a future version."); + } + + if (userPropertiesFromOption) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the user properties legacy options \"-up\" or \"--userProperty\" and the current \"--user-property\" is used. Please only use \"--user-property\" as the legacy options will be removed in a future version."); + } + userPropertiesFromLegacyOption = true; + userProperties = userPropertiesLegacy; + } + + private @Nullable File outputFile = null; + + @SuppressWarnings("unused") + @CommandLine.Option(names = {"--output-to-file"}, description = "A file to which the received publish messages will be written") - private @Nullable File outputFile; + private void outputFile(final @NotNull File outputFile) { + if (this.outputFile != null) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the output file legacy options \"-of\" or \"--outputToFile\" and the current \"--output-to-file\" is used. Please only use \"--output-to-file\" as the legacy options will be removed in a future version."); + } + this.outputFile = outputFile; + } + + @SuppressWarnings("unused") + @Deprecated(since = "4.34.0", forRemoval = true) + @CommandLine.Option(names = {"-of", "--outputToFile"}, + hidden = true, + description = "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". They will be removed in a future version") + private void outputFileLegacy(final @NotNull File outputFileLegacy) { + deprecationWarnings.add( + "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". They will be removed in a future version."); + + if (this.outputFile != null) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the output file legacy options \"-of\" or \"--outputToFile\" and the current \"--output-to-file\" is used. Please only use \"--output-to-file\" as the legacy options will be removed in a future version."); + } + this.outputFile = outputFileLegacy; + } + + private boolean isPayloadEncodeToBase64 = false; @SuppressWarnings("unused") - @CommandLine.Option(names = {"-b64", "--base64"}, + @CommandLine.Option(names = {"--base64"}, description = "Specify the encoding of the received messages as Base64 (default: false)") - private boolean base64; + private void isMessageBase64Encoded(final boolean base64) { + if (isPayloadEncodeToBase64) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the base64 legacy options \"-b64\" and the current \"--base64\" is used. Please only use \"--base64\" as the legacy options will be removed in a future version."); + } + isPayloadEncodeToBase64 = base64; + } + + @SuppressWarnings("unused") + @Deprecated(since = "4.34.0", forRemoval = true) + @CommandLine.Option(names = {"-b64"}, + hidden = true, + description = "Option \"-b64\" is legacy, please use \"--base64\". It will be removed in a future version") + private void isMessageBase64EncodedLegacy(final boolean base64Legacy) { + deprecationWarnings.add( + "Option \"-b64\" is legacy, please use \"--base64\". It will be removed in a future version."); + + if (isPayloadEncodeToBase64) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the base64 legacy options \"-b64\" and the current \"--base64\" is used. Please only use \"--base64\" as the legacy options will be removed in a future version."); + } + isPayloadEncodeToBase64 = base64Legacy; + } + + private boolean jsonOutput = false; @SuppressWarnings("unused") - @CommandLine.Option(names = {"-J", "--jsonOutput"}, - defaultValue = "false", + @CommandLine.Option(names = {"-J", "--json-output"}, description = "Print the received publishes in pretty JSON format") - private boolean jsonOutput; + private void jsonOutput(final boolean jsonOutput) { + if (this.jsonOutput) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the json output legacy options \"--jsonOutput\" and the current \"-J\" or \"--json-output\" is used. Please only use \"-J\" or \"--json-output\" as the legacy options will be removed in a future version."); + } + this.jsonOutput = jsonOutput; + } + + @SuppressWarnings("unused") + @Deprecated(since = "4.34.0", forRemoval = true) + @CommandLine.Option(names = {"--jsonOutput"}, + hidden = true, + description = "Option \"--jsonOutput\" is legacy, please use \"--json-output\". It will be removed in a future version") + private void jsonOutputLegacy(final boolean jsonOutputLegacy) { + deprecationWarnings.add( + "Option \"--jsonOutput\" is legacy, please use \"--json-output\". It will be removed in a future version."); + + if (jsonOutput) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the json output legacy options \"--jsonOutput\" and the current \"-J\" or \"--json-output\" is used. Please only use \"-J\" or \"--json-output\" as the legacy options will be removed in a future version."); + } + jsonOutput = true; + } + + private boolean showTopics = false; @SuppressWarnings("unused") - @CommandLine.Option(names = {"-T", "--showTopics"}, - defaultValue = "false", + @CommandLine.Option(names = {"-T", "--show-topics"}, description = "Prepend the specific topic name to the received publish") - private boolean showTopics; + private void showTopics(final boolean showTopics) { + if (this.showTopics) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the show topics legacy options \"--showTopics\" and the current \"-T\" or \"--show-topics\" is used. Please only use \"-T\" or \"--show-topics\" as the legacy options will be removed in a future version."); + } + this.showTopics = showTopics; + } + + @SuppressWarnings("unused") + @Deprecated(since = "4.34.0", forRemoval = true) + @CommandLine.Option(names = {"--showTopics"}, + hidden = true, + description = "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". It will be removed in a future version") + private void showTopicsLegacy(final boolean showTopicsLegacy) { + deprecationWarnings.add( + "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". It will be removed in a future version."); + + if (this.showTopics) { + throw new CommandLine.ParameterException(spec.commandLine(), + "A mix of the show topics legacy options \"--showTopics\" and the current \"-T\" or \"--show-topics\" is used. Please only use \"-T\" or \"--show-topics\" as the legacy options will be removed in a future version."); + } + showTopics = true; + } private boolean printToSTDOUT = false; - public SubscribeOptions() { + public SubscribeOptions(final @NotNull List deprecationWarnings) { + this.deprecationWarnings = deprecationWarnings; setDefaultOptions(); } @@ -98,8 +232,8 @@ public boolean isPrintToSTDOUT() { return printToSTDOUT; } - public boolean isBase64() { - return base64; + public boolean isPayloadEncodeToBase64() { + return isPayloadEncodeToBase64; } public boolean isJsonOutput() { @@ -181,7 +315,7 @@ public void setDefaultOptions() { ", printToSTDOUT=" + printToSTDOUT + ", base64=" + - base64 + + isPayloadEncodeToBase64 + ", jsonOutput=" + jsonOutput + ", showTopics=" + diff --git a/src/main/java/com/hivemq/cli/commands/shell/ContextSubscribeCommand.java b/src/main/java/com/hivemq/cli/commands/shell/ContextSubscribeCommand.java index bf952cea4..e3020e121 100644 --- a/src/main/java/com/hivemq/cli/commands/shell/ContextSubscribeCommand.java +++ b/src/main/java/com/hivemq/cli/commands/shell/ContextSubscribeCommand.java @@ -25,6 +25,8 @@ import picocli.CommandLine; import javax.inject.Inject; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; import java.util.Scanner; import java.util.concurrent.Callable; @@ -40,6 +42,8 @@ public class ContextSubscribeCommand extends ShellContextCommand implements Call private static final int IDLE_TIME = 1000; + private final @NotNull List deprecationWarnings = new ArrayList<>(); + @SuppressWarnings("unused") @CommandLine.Option(names = {"-s", "--stay"}, defaultValue = "false", @@ -55,7 +59,7 @@ private void printToSTDOUT(final boolean printToSTDOUT) { } @CommandLine.Mixin - private final @NotNull SubscribeOptions subscribeOptions = new SubscribeOptions(); + private final @NotNull SubscribeOptions subscribeOptions = new SubscribeOptions(deprecationWarnings); @Inject public ContextSubscribeCommand(final @NotNull MqttClientExecutor mqttClientExecutor) { @@ -66,6 +70,8 @@ public ContextSubscribeCommand(final @NotNull MqttClientExecutor mqttClientExecu public @NotNull Integer call() { Logger.trace("Command {}", this); + LoggerUtils.logDeprecatedOptions(deprecationWarnings); + if (contextClient == null) { Logger.error("The client to subscribe with does not exist"); return 1; diff --git a/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt3PublishCallback.java b/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt3PublishCallback.java index 370bb4209..803cd551d 100644 --- a/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt3PublishCallback.java +++ b/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt3PublishCallback.java @@ -42,7 +42,7 @@ public class SubscribeMqtt3PublishCallback implements Consumer { SubscribeMqtt3PublishCallback(final @NotNull SubscribeOptions subscribeOptions, final @NotNull Mqtt3Client client) { printToStdout = subscribeOptions.isPrintToSTDOUT(); outputFile = subscribeOptions.getOutputFile(); - isBase64 = subscribeOptions.isBase64(); + isBase64 = subscribeOptions.isPayloadEncodeToBase64(); isJsonOutput = subscribeOptions.isJsonOutput(); showTopics = subscribeOptions.isShowTopics(); this.client = client; diff --git a/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt5PublishCallback.java b/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt5PublishCallback.java index e245f34ee..3b69d78d5 100644 --- a/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt5PublishCallback.java +++ b/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt5PublishCallback.java @@ -42,7 +42,7 @@ public class SubscribeMqtt5PublishCallback implements Consumer { SubscribeMqtt5PublishCallback(final @NotNull SubscribeOptions subscribeOptions, final @NotNull Mqtt5Client client) { printToStdout = subscribeOptions.isPrintToSTDOUT(); outputFile = subscribeOptions.getOutputFile(); - isBase64 = subscribeOptions.isBase64(); + isBase64 = subscribeOptions.isPayloadEncodeToBase64(); isJsonOutput = subscribeOptions.isJsonOutput(); showTopics = subscribeOptions.isShowTopics(); this.client = client; diff --git a/src/main/java/com/hivemq/cli/utils/LoggerUtils.java b/src/main/java/com/hivemq/cli/utils/LoggerUtils.java index 69db4cf09..ca1a4a5e8 100644 --- a/src/main/java/com/hivemq/cli/utils/LoggerUtils.java +++ b/src/main/java/com/hivemq/cli/utils/LoggerUtils.java @@ -34,6 +34,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -56,7 +57,7 @@ public static void useDefaultLogging(final @Nullable Map extende // TinyLog configuration // File Writer (creates logfiles under .mqtt-cli/logs folder) - final Map configurationMap = new HashMap() {{ + final Map configurationMap = new HashMap<>() {{ put("writer", "file"); put("writer.format", logfileFormatPattern); put("writer.file", logfilePath.toString()); @@ -73,7 +74,7 @@ public static void useDefaultLogging(final @Nullable Map extende public static void setupConsoleLogging(final boolean logToLogfile, final @NotNull String logLevel) { // TinyLog configuration - final Map configurationMap = new HashMap() {{ + final Map configurationMap = new HashMap<>() {{ put("writer1", "console"); if (logLevel.equals("debug") || logLevel.equals("trace")) { put("writer1.format", "{message}"); @@ -94,7 +95,7 @@ public static void turnOffConsoleLogging(final boolean logToLogfile) { if (logToLogfile) { LoggerUtils.useDefaultLogging(); } else { - final Map configurationMap = new HashMap() {{ + final Map configurationMap = new HashMap<>() {{ put("writer.level", "off"); }}; Configuration.replace(configurationMap); @@ -140,4 +141,17 @@ public static void logShellError(final @NotNull String message, final @NotNull E Logger.error(exception, "{}. Use 'mqtt sh -l' to see more detailed information in the logfile.", message); } } + + public static void logDeprecatedOptions(final @NotNull List deprecationWarnings) { + if (!deprecationWarnings.isEmpty()) { + if (deprecationWarnings.size() == 1) { + Logger.warn(deprecationWarnings.get(0)); + } else { + Logger.warn("There are deprecated options used in this command:"); + for (final String deprecatedWarning : deprecationWarnings) { + Logger.warn(" - " + deprecatedWarning); + } + } + } + } } diff --git a/src/systemTest/java/com/hivemq/cli/commands/cli/subscribe/SubscribeDeprecationST.java b/src/systemTest/java/com/hivemq/cli/commands/cli/subscribe/SubscribeDeprecationST.java new file mode 100644 index 000000000..fed4390ae --- /dev/null +++ b/src/systemTest/java/com/hivemq/cli/commands/cli/subscribe/SubscribeDeprecationST.java @@ -0,0 +1,406 @@ +/* + * Copyright 2019-present HiveMQ and the HiveMQ Community + * + * Licensed 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 com.hivemq.cli.commands.cli.subscribe; + +import com.google.common.collect.ImmutableList; +import com.google.gson.JsonObject; +import com.hivemq.cli.utils.broker.HiveMQExtension; +import com.hivemq.cli.utils.cli.MqttCliAsyncExtension; +import com.hivemq.cli.utils.cli.results.ExecutionResultAsync; +import com.hivemq.client.mqtt.datatypes.MqttQos; +import com.hivemq.client.mqtt.mqtt5.Mqtt5BlockingClient; +import com.hivemq.client.mqtt.mqtt5.Mqtt5Client; +import com.hivemq.extension.sdk.api.packets.general.Qos; +import com.hivemq.extension.sdk.api.packets.subscribe.RetainHandling; +import com.hivemq.extension.sdk.api.packets.subscribe.Subscription; +import com.hivemq.extensions.packets.general.UserPropertiesImpl; +import com.hivemq.extensions.packets.subscribe.SubscriptionImpl; +import com.hivemq.mqtt.message.mqtt5.MqttUserProperty; +import org.jetbrains.annotations.NotNull; +import org.junit.jupiter.api.Timeout; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Base64; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static com.hivemq.cli.utils.broker.assertions.SubscribeAssertion.assertSubscribePacket; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class SubscribeDeprecationST { + + @RegisterExtension + @SuppressWarnings("JUnitMalformedDeclaration") + private final @NotNull HiveMQExtension hivemq = HiveMQExtension.builder().build(); + + @RegisterExtension + @SuppressWarnings("JUnitMalformedDeclaration") + private final @NotNull MqttCliAsyncExtension mqttCli = new MqttCliAsyncExtension(); + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_userProperties_legacyInformation(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("-up"); + subscribeCommand.add("key1=value1"); + subscribeCommand.add("-up"); + subscribeCommand.add("key2=value2"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + + executionResult.awaitStdErr( + "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". They will be removed in a future version."); + + assertSubscribe(executionResult); + + if (mqttVersion == '3') { + executionResult.awaitStdErr("Subscribe user properties were set but are unused in MQTT version MQTT_3_1_1"); + } + + publishMessage("message"); + + executionResult.awaitStdOut("message"); + + assertSubscribePacket(hivemq.getSubscribePackets().get(0), subscribeAssertion -> { + final List expectedSubscriptions = List.of(new SubscriptionImpl("topic", + Qos.EXACTLY_ONCE, + RetainHandling.SEND, + false, + false)); + + subscribeAssertion.setSubscriptions(expectedSubscriptions); + if (mqttVersion == '5') { + final UserPropertiesImpl expectedUserProperties = UserPropertiesImpl.of(ImmutableList.of( + MqttUserProperty.of("key1", "value1"), + MqttUserProperty.of("key2", "value2"))); + subscribeAssertion.setUserProperties(expectedUserProperties); + } + }); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_userProperties_mixedLegacyAndCurrent(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("-up"); + subscribeCommand.add("key1=value1"); + subscribeCommand.add("--user-property"); + subscribeCommand.add("key2=value2"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + + executionResult.awaitStdErr( + "A mix of the user properties legacy options \"-up\" or \"--userProperty\" and the current \"--user-property\" is used. Please only use \"--user-property\" as the legacy options will be removed in a future version."); + + final List subscribeCommand2 = defaultSubscribeCommand(mqttVersion); + subscribeCommand2.add("--user-property"); + subscribeCommand2.add("key2=value2"); + subscribeCommand2.add("-up"); + subscribeCommand2.add("key1=value1"); + + final ExecutionResultAsync executionResult2 = mqttCli.executeAsync(subscribeCommand2); + + executionResult2.awaitStdErr( + "A mix of the user properties legacy options \"-up\" or \"--userProperty\" and the current \"--user-property\" is used. Please only use \"--user-property\" as the legacy options will be removed in a future version."); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_outputFile_legacyInformation(final char mqttVersion) throws Exception { + final Path messageFile = Files.createTempFile("message-file", ".txt"); + messageFile.toFile().deleteOnExit(); + + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("-of"); + subscribeCommand.add(messageFile.toString()); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + + executionResult.awaitStdErr( + "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". They will be removed in a future version."); + + assertSubscribe(executionResult); + + publishMessage("message"); + + executionResult.awaitStdOut("message"); + + final List readLines = Files.readAllLines(messageFile); + assertEquals(1, readLines.size()); + assertEquals("message", readLines.get(0)); + + assertSubscribePacket(hivemq.getSubscribePackets().get(0), subscribeAssertion -> { + final List expectedSubscriptions = List.of(new SubscriptionImpl("topic", + Qos.EXACTLY_ONCE, + RetainHandling.SEND, + false, + false)); + subscribeAssertion.setSubscriptions(expectedSubscriptions); + }); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_outputFile_mixedLegacyAndCurrent(final char mqttVersion) throws Exception { + final Path messageFile = Files.createTempFile("message-file", ".txt"); + messageFile.toFile().deleteOnExit(); + + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("-of"); + subscribeCommand.add(messageFile.toString()); + subscribeCommand.add("--output-to-file"); + subscribeCommand.add(messageFile.toString()); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + executionResult.awaitStdErr( + "A mix of the output file legacy options \"-of\" or \"--outputToFile\" and the current \"--output-to-file\" is used. Please only use \"--output-to-file\" as the legacy options will be removed in a future version."); + + final List subscribeCommand2 = defaultSubscribeCommand(mqttVersion); + subscribeCommand2.add("-of"); + subscribeCommand2.add(messageFile.toString()); + subscribeCommand2.add("--output-to-file"); + subscribeCommand2.add(messageFile.toString()); + + final ExecutionResultAsync executionResult2 = mqttCli.executeAsync(subscribeCommand2); + executionResult2.awaitStdErr( + "A mix of the output file legacy options \"-of\" or \"--outputToFile\" and the current \"--output-to-file\" is used. Please only use \"--output-to-file\" as the legacy options will be removed in a future version."); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_base64_legacyInformation(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("-b64"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + + executionResult.awaitStdErr( + "Option \"-b64\" is legacy, please use \"--base64\". It will be removed in a future version."); + + assertSubscribe(executionResult); + + publishMessage("message"); + + final String encodedPayload = Base64.getEncoder().encodeToString("message".getBytes(StandardCharsets.UTF_8)); + executionResult.awaitStdOut(encodedPayload); + + assertSubscribePacket(hivemq.getSubscribePackets().get(0), subscribeAssertion -> { + final List expectedSubscriptions = List.of(new SubscriptionImpl("topic", + Qos.EXACTLY_ONCE, + RetainHandling.SEND, + false, + false)); + subscribeAssertion.setSubscriptions(expectedSubscriptions); + }); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_base64_mixedLegacyAndCurrent(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("-b64"); + subscribeCommand.add("--base64"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + executionResult.awaitStdErr( + "A mix of the base64 legacy options \"-b64\" and the current \"--base64\" is used. Please only use \"--base64\" as the legacy options will be removed in a future version."); + + final List subscribeCommand2 = defaultSubscribeCommand(mqttVersion); + subscribeCommand2.add("--base64"); + subscribeCommand2.add("-b64"); + + final ExecutionResultAsync executionResult2 = mqttCli.executeAsync(subscribeCommand2); + executionResult2.awaitStdErr( + "A mix of the base64 legacy options \"-b64\" and the current \"--base64\" is used. Please only use \"--base64\" as the legacy options will be removed in a future version."); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_showJson_legacyInformation(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("--jsonOutput"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + + executionResult.awaitStdErr( + "Option \"--jsonOutput\" is legacy, please use \"--json-output\". It will be removed in a future version."); + + assertSubscribe(executionResult); + + final JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("property1", "value1"); + jsonObject.addProperty("property2", "value2"); + jsonObject.addProperty("property3", "value3"); + publishMessage(jsonObject.toString()); + + executionResult.awaitStdOut("{\n" + + " \"topic\": \"topic\",\n" + + " \"payload\": {\n" + + " \"property1\": \"value1\",\n" + + " \"property2\": \"value2\",\n" + + " \"property3\": \"value3\"\n" + + " },\n"); + executionResult.awaitStdOut("\"qos\": \"EXACTLY_ONCE\","); + executionResult.awaitStdOut("\"receivedAt\":"); + executionResult.awaitStdOut("\"retain\": false"); + executionResult.awaitStdOut("}"); + + assertSubscribePacket(hivemq.getSubscribePackets().get(0), subscribeAssertion -> { + final List expectedSubscriptions = List.of(new SubscriptionImpl("topic", + Qos.EXACTLY_ONCE, + RetainHandling.SEND, + false, + false)); + subscribeAssertion.setSubscriptions(expectedSubscriptions); + }); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_showJson_mixedLegacyAndCurrent(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("--jsonOutput"); + subscribeCommand.add("--json-output"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + executionResult.awaitStdErr( + "A mix of the json output legacy options \"--jsonOutput\" and the current \"-J\" or \"--json-output\" is used. Please only use \"-J\" or \"--json-output\" as the legacy options will be removed in a future version."); + + final List subscribeCommand2 = defaultSubscribeCommand(mqttVersion); + subscribeCommand2.add("--json-output"); + subscribeCommand2.add("--jsonOutput"); + + final ExecutionResultAsync executionResult2 = mqttCli.executeAsync(subscribeCommand2); + executionResult2.awaitStdErr( + "A mix of the json output legacy options \"--jsonOutput\" and the current \"-J\" or \"--json-output\" is used. Please only use \"-J\" or \"--json-output\" as the legacy options will be removed in a future version."); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_showTopic_legacyInformation(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("--showTopics"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + + executionResult.awaitStdErr( + "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". It will be removed in a future version."); + + assertSubscribe(executionResult); + + publishMessage("message"); + + executionResult.awaitStdOut("topic: message"); + + assertSubscribePacket(hivemq.getSubscribePackets().get(0), subscribeAssertion -> { + final List expectedSubscriptions = List.of(new SubscriptionImpl("topic", + Qos.EXACTLY_ONCE, + RetainHandling.SEND, + false, + false)); + subscribeAssertion.setSubscriptions(expectedSubscriptions); + }); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_showTopic_mixedLegacyAndCurrent(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("--showTopics"); + subscribeCommand.add("--show-topics"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + executionResult.awaitStdErr( + "A mix of the show topics legacy options \"--showTopics\" and the current \"-T\" or \"--show-topics\" is used. Please only use \"-T\" or \"--show-topics\" as the legacy options will be removed in a future version."); + + final List subscribeCommand2 = defaultSubscribeCommand(mqttVersion); + subscribeCommand2.add("--show-topics"); + subscribeCommand2.add("--showTopics"); + + final ExecutionResultAsync executionResult2 = mqttCli.executeAsync(subscribeCommand2); + executionResult2.awaitStdErr( + "A mix of the show topics legacy options \"--showTopics\" and the current \"-T\" or \"--show-topics\" is used. Please only use \"-T\" or \"--show-topics\" as the legacy options will be removed in a future version."); + } + + @ParameterizedTest + @Timeout(value = 3, unit = TimeUnit.MINUTES) + @ValueSource(chars = {'3', '5'}) + void test_multipleLegacyInformation(final char mqttVersion) throws Exception { + final List subscribeCommand = defaultSubscribeCommand(mqttVersion); + subscribeCommand.add("--showTopics"); + subscribeCommand.add("--jsonOutput"); + + final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); + + executionResult.awaitStdErr("There are deprecated options used in this command:"); + } + + private @NotNull List defaultSubscribeCommand(final char mqttVersion) { + final ArrayList subscribeCommand = new ArrayList<>(); + subscribeCommand.add("sub"); + subscribeCommand.add("-h"); + subscribeCommand.add(hivemq.getHost()); + subscribeCommand.add("-p"); + subscribeCommand.add(String.valueOf(hivemq.getMqttPort())); + subscribeCommand.add("-V"); + subscribeCommand.add(String.valueOf(mqttVersion)); + subscribeCommand.add("-i"); + subscribeCommand.add("cliTest"); + subscribeCommand.add("-t"); + subscribeCommand.add("topic"); + subscribeCommand.add("-d"); + return subscribeCommand; + } + + private void assertSubscribe(final @NotNull ExecutionResultAsync executionResultAsync) { + executionResultAsync.awaitStdOut("sending CONNECT"); + executionResultAsync.awaitStdOut("received CONNACK"); + executionResultAsync.awaitStdOut("sending SUBSCRIBE"); + executionResultAsync.awaitStdOut("received SUBACK"); + } + + private void publishMessage(final @NotNull String message) { + final Mqtt5BlockingClient publisher = Mqtt5Client.builder() + .identifier("publisher") + .serverHost(hivemq.getHost()) + .serverPort(hivemq.getMqttPort()) + .buildBlocking(); + publisher.connect(); + publisher.publishWith() + .topic("topic") + .payload(message.getBytes(StandardCharsets.UTF_8)) + .qos(MqttQos.EXACTLY_ONCE) + .send(); + } + +} From 4f3693b9f567bfb8872d702ff8d020c707267eba Mon Sep 17 00:00:00 2001 From: Lukas Brand Date: Wed, 2 Oct 2024 18:10:13 +0200 Subject: [PATCH 2/4] Update documentation --- docs/_includes/options/subscribe-options.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/_includes/options/subscribe-options.md b/docs/_includes/options/subscribe-options.md index a1fcff23b..cd68c6737 100644 --- a/docs/_includes/options/subscribe-options.md +++ b/docs/_includes/options/subscribe-options.md @@ -1,9 +1,9 @@ -| Option | Long Version | Explanation | Default | -|--------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| -| `-t` | `--topic` | The MQTT topic the client will subscribe to. | | -| `-q` | `--qos` | Define the quality of service level. If only one QoS is specified it will be used for all topics.
You can define a specific QoS level for every topic. The corresponding QoS levels will be matched in order to the given topics. | `0` | -| `-of` | `--outputToFile` | Append the received publish messages to a file. Creates the file if it does not exist. | | -| `-b64` | `--base64` | Whether the received publish messages will be base64 encoded. | `false` | -| `-J` | `--jsonOutput` | Print the received publishes in pretty JSON format. | `false` | -| `-T` | `--showTopics` | Prepend the specific topic name to the received publish. | `false` | -| `-up` | `--userProperty` | A user property of the subscribe message. | | +| Option | Long Version | Explanation | Default | +|--------|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------| +| `-t` | `--topic` | The MQTT topic the client will subscribe to. | | +| `-q` | `--qos` | Define the quality of service level. If only one QoS is specified it will be used for all topics.
You can define a specific QoS level for every topic. The corresponding QoS levels will be matched in order to the given topics. | `0` | +| | `--output-to-file` | Append the received publish messages to a file. Creates the file if it does not exist. | | +| | `--base64` | Whether the received publish messages will be base64 encoded. | `false` | +| `-J` | `--json-output` | Print the received publishes in pretty JSON format. | `false` | +| `-T` | `--show-topics` | Prepend the specific topic name to the received publish. | `false` | +| | `--user-property` | A user property of the subscribe message. | | From 2d063b02409ed2034dfc508dedf6b69f34266334 Mon Sep 17 00:00:00 2001 From: Lukas Brand Date: Mon, 7 Oct 2024 14:05:27 +0200 Subject: [PATCH 3/4] Apply review comments --- .../commands/options/SubscribeOptions.java | 37 +++++++++---------- .../mqtt/SubscribeMqtt3PublishCallback.java | 2 +- .../mqtt/SubscribeMqtt5PublishCallback.java | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java b/src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java index a62d6d5a7..2bc82a7c6 100644 --- a/src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java +++ b/src/main/java/com/hivemq/cli/commands/options/SubscribeOptions.java @@ -77,12 +77,12 @@ private void userProperties(final @NotNull Mqtt5UserProperty @NotNull [] userPro @CommandLine.Option(names = {"-up", "--userProperty"}, hidden = true, converter = Mqtt5UserPropertyConverter.class, - description = "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". They will be removed in a future version.") + description = "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". Legacy options will be removed in a future version.") private void userPropertiesLegacy(final @NotNull Mqtt5UserProperty @NotNull [] userPropertiesLegacy) { //only show message once as this method is executed multiple times if (!userPropertiesFromLegacyOption) { deprecationWarnings.add( - "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". They will be removed in a future version."); + "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". Legacy options will be removed in a future version."); } if (userPropertiesFromOption) { @@ -110,10 +110,10 @@ private void outputFile(final @NotNull File outputFile) { @Deprecated(since = "4.34.0", forRemoval = true) @CommandLine.Option(names = {"-of", "--outputToFile"}, hidden = true, - description = "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". They will be removed in a future version") + description = "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". Legacy options will be removed in a future version") private void outputFileLegacy(final @NotNull File outputFileLegacy) { deprecationWarnings.add( - "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". They will be removed in a future version."); + "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". Legacy options will be removed in a future version."); if (this.outputFile != null) { throw new CommandLine.ParameterException(spec.commandLine(), @@ -122,33 +122,33 @@ private void outputFileLegacy(final @NotNull File outputFileLegacy) { this.outputFile = outputFileLegacy; } - private boolean isPayloadEncodeToBase64 = false; + private boolean isEncodePayloadInBase64 = false; @SuppressWarnings("unused") @CommandLine.Option(names = {"--base64"}, description = "Specify the encoding of the received messages as Base64 (default: false)") private void isMessageBase64Encoded(final boolean base64) { - if (isPayloadEncodeToBase64) { + if (isEncodePayloadInBase64) { throw new CommandLine.ParameterException(spec.commandLine(), "A mix of the base64 legacy options \"-b64\" and the current \"--base64\" is used. Please only use \"--base64\" as the legacy options will be removed in a future version."); } - isPayloadEncodeToBase64 = base64; + isEncodePayloadInBase64 = base64; } @SuppressWarnings("unused") @Deprecated(since = "4.34.0", forRemoval = true) @CommandLine.Option(names = {"-b64"}, hidden = true, - description = "Option \"-b64\" is legacy, please use \"--base64\". It will be removed in a future version") + description = "Option \"-b64\" is legacy, please use \"--base64\". The legacy option will be removed in a future version") private void isMessageBase64EncodedLegacy(final boolean base64Legacy) { deprecationWarnings.add( - "Option \"-b64\" is legacy, please use \"--base64\". It will be removed in a future version."); + "Option \"-b64\" is legacy, please use \"--base64\". The legacy option will be removed in a future version."); - if (isPayloadEncodeToBase64) { + if (isEncodePayloadInBase64) { throw new CommandLine.ParameterException(spec.commandLine(), "A mix of the base64 legacy options \"-b64\" and the current \"--base64\" is used. Please only use \"--base64\" as the legacy options will be removed in a future version."); } - isPayloadEncodeToBase64 = base64Legacy; + isEncodePayloadInBase64 = base64Legacy; } private boolean jsonOutput = false; @@ -168,10 +168,10 @@ private void jsonOutput(final boolean jsonOutput) { @Deprecated(since = "4.34.0", forRemoval = true) @CommandLine.Option(names = {"--jsonOutput"}, hidden = true, - description = "Option \"--jsonOutput\" is legacy, please use \"--json-output\". It will be removed in a future version") + description = "Option \"--jsonOutput\" is legacy, please use \"--json-output\". The legacy option will be removed in a future version") private void jsonOutputLegacy(final boolean jsonOutputLegacy) { deprecationWarnings.add( - "Option \"--jsonOutput\" is legacy, please use \"--json-output\". It will be removed in a future version."); + "Option \"--jsonOutput\" is legacy, please use \"--json-output\". The legacy option will be removed in a future version."); if (jsonOutput) { throw new CommandLine.ParameterException(spec.commandLine(), @@ -197,10 +197,10 @@ private void showTopics(final boolean showTopics) { @Deprecated(since = "4.34.0", forRemoval = true) @CommandLine.Option(names = {"--showTopics"}, hidden = true, - description = "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". It will be removed in a future version") + description = "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". The legacy option will be removed in a future version") private void showTopicsLegacy(final boolean showTopicsLegacy) { deprecationWarnings.add( - "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". It will be removed in a future version."); + "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". The legacy option will be removed in a future version."); if (this.showTopics) { throw new CommandLine.ParameterException(spec.commandLine(), @@ -232,8 +232,8 @@ public boolean isPrintToSTDOUT() { return printToSTDOUT; } - public boolean isPayloadEncodeToBase64() { - return isPayloadEncodeToBase64; + public boolean isEncodePayloadInBase64() { + return isEncodePayloadInBase64; } public boolean isJsonOutput() { @@ -314,8 +314,7 @@ public void setDefaultOptions() { outputFile + ", printToSTDOUT=" + printToSTDOUT + - ", base64=" + - isPayloadEncodeToBase64 + + ", base64=" + isEncodePayloadInBase64 + ", jsonOutput=" + jsonOutput + ", showTopics=" + diff --git a/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt3PublishCallback.java b/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt3PublishCallback.java index 803cd551d..f70a26d2a 100644 --- a/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt3PublishCallback.java +++ b/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt3PublishCallback.java @@ -42,7 +42,7 @@ public class SubscribeMqtt3PublishCallback implements Consumer { SubscribeMqtt3PublishCallback(final @NotNull SubscribeOptions subscribeOptions, final @NotNull Mqtt3Client client) { printToStdout = subscribeOptions.isPrintToSTDOUT(); outputFile = subscribeOptions.getOutputFile(); - isBase64 = subscribeOptions.isPayloadEncodeToBase64(); + isBase64 = subscribeOptions.isEncodePayloadInBase64(); isJsonOutput = subscribeOptions.isJsonOutput(); showTopics = subscribeOptions.isShowTopics(); this.client = client; diff --git a/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt5PublishCallback.java b/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt5PublishCallback.java index 3b69d78d5..7d4e5224a 100644 --- a/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt5PublishCallback.java +++ b/src/main/java/com/hivemq/cli/mqtt/SubscribeMqtt5PublishCallback.java @@ -42,7 +42,7 @@ public class SubscribeMqtt5PublishCallback implements Consumer { SubscribeMqtt5PublishCallback(final @NotNull SubscribeOptions subscribeOptions, final @NotNull Mqtt5Client client) { printToStdout = subscribeOptions.isPrintToSTDOUT(); outputFile = subscribeOptions.getOutputFile(); - isBase64 = subscribeOptions.isPayloadEncodeToBase64(); + isBase64 = subscribeOptions.isEncodePayloadInBase64(); isJsonOutput = subscribeOptions.isJsonOutput(); showTopics = subscribeOptions.isShowTopics(); this.client = client; From 399fe1fde66fcac9f4757ffb0e560497ac530288 Mon Sep 17 00:00:00 2001 From: Lukas Brand Date: Mon, 7 Oct 2024 15:16:24 +0200 Subject: [PATCH 4/4] Fixed tests to use new logs --- .../commands/cli/subscribe/SubscribeDeprecationST.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/systemTest/java/com/hivemq/cli/commands/cli/subscribe/SubscribeDeprecationST.java b/src/systemTest/java/com/hivemq/cli/commands/cli/subscribe/SubscribeDeprecationST.java index fed4390ae..9c6eaf220 100644 --- a/src/systemTest/java/com/hivemq/cli/commands/cli/subscribe/SubscribeDeprecationST.java +++ b/src/systemTest/java/com/hivemq/cli/commands/cli/subscribe/SubscribeDeprecationST.java @@ -70,7 +70,7 @@ void test_userProperties_legacyInformation(final char mqttVersion) throws Except final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); executionResult.awaitStdErr( - "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". They will be removed in a future version."); + "Options \"-up\" and \"--userProperty\" are legacy, please use \"--user-property\". Legacy options will be removed in a future version."); assertSubscribe(executionResult); @@ -140,7 +140,7 @@ void test_outputFile_legacyInformation(final char mqttVersion) throws Exception final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); executionResult.awaitStdErr( - "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". They will be removed in a future version."); + "Options \"-of\" and \"--outputToFile\" are legacy, please use \"--output-to-file\". Legacy options will be removed in a future version."); assertSubscribe(executionResult); @@ -200,7 +200,7 @@ void test_base64_legacyInformation(final char mqttVersion) throws Exception { final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); executionResult.awaitStdErr( - "Option \"-b64\" is legacy, please use \"--base64\". It will be removed in a future version."); + "Option \"-b64\" is legacy, please use \"--base64\". The legacy option will be removed in a future version."); assertSubscribe(executionResult); @@ -250,7 +250,7 @@ void test_showJson_legacyInformation(final char mqttVersion) throws Exception { final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); executionResult.awaitStdErr( - "Option \"--jsonOutput\" is legacy, please use \"--json-output\". It will be removed in a future version."); + "Option \"--jsonOutput\" is legacy, please use \"--json-output\". The legacy option will be removed in a future version."); assertSubscribe(executionResult); @@ -313,7 +313,7 @@ void test_showTopic_legacyInformation(final char mqttVersion) throws Exception { final ExecutionResultAsync executionResult = mqttCli.executeAsync(subscribeCommand); executionResult.awaitStdErr( - "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". It will be removed in a future version."); + "Option \"--showTopics\" is legacy, please use \"-T\" or \"--show-topics\". The legacy option will be removed in a future version."); assertSubscribe(executionResult);