nizhikov commented on code in PR #15832:
URL: https://github.com/apache/kafka/pull/15832#discussion_r1584629877


##########
core/src/test/java/kafka/admin/UserScramCredentialsCommandTest.java:
##########
@@ -0,0 +1,178 @@
+/*
+ * 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 kafka.admin;
+
+import kafka.server.BaseRequestTest;
+import kafka.utils.Exit;
+import org.apache.kafka.test.TestUtils;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import scala.Console;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+import java.util.OptionalInt;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@SuppressWarnings("dontUseSystemExit")
+public class UserScramCredentialsCommandTest extends BaseRequestTest {
+    private static final Logger log = 
LoggerFactory.getLogger(UserScramCredentialsCommandTest.class);
+
+    @Override
+    public int brokerCount() {
+        return 1;
+    }
+
+    static class ConfigCommandResult {
+        public final String stdout;
+        public final OptionalInt exitStatus;
+
+        public ConfigCommandResult(String stdout) {
+            this(stdout, OptionalInt.empty());
+        }
+
+        public ConfigCommandResult(String stdout, OptionalInt exitStatus) {
+            this.stdout = stdout;
+            this.exitStatus = exitStatus;
+        }
+    }
+
+    private ConfigCommandResult runConfigCommandViaBroker(String...args) 
throws UnsupportedEncodingException {
+        ByteArrayOutputStream byteArrayOutputStream = new 
ByteArrayOutputStream();
+        String utf8 = StandardCharsets.UTF_8.name();
+        PrintStream printStream = new PrintStream(byteArrayOutputStream, true, 
utf8);
+        AtomicReference<OptionalInt> exitStatus = new 
AtomicReference<>(OptionalInt.empty());
+        Exit.setExitProcedure((status, __) -> {
+            exitStatus.set(OptionalInt.of((Integer) status));
+            throw new RuntimeException();
+        });
+
+        List<String> commandArgs = new 
ArrayList<>(Arrays.asList("--bootstrap-server", 
bootstrapServers(listenerName())));
+        commandArgs.addAll(Arrays.asList(args));
+        try {
+            Console.withOut(printStream, () -> {
+                ConfigCommand.main(commandArgs.toArray(new String[0]));
+                return null;
+            });
+            return new 
ConfigCommandResult(byteArrayOutputStream.toString(utf8));
+        } catch (Exception e) {
+            log.debug("Exception running ConfigCommand " + String.join(" ", 
commandArgs), e);

Review Comment:
   yes. removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to