fvaleri commented on code in PR #13136: URL: https://github.com/apache/kafka/pull/13136#discussion_r1093501099
########## tools/src/test/java/org/apache/kafka/tools/JmxToolTest.java: ########## @@ -0,0 +1,282 @@ +/* + * 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.kafka.tools; + +import org.apache.kafka.common.utils.AppInfoParser; +import org.apache.kafka.common.utils.Exit; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import javax.management.MBeanServer; +import javax.management.ObjectName; +import javax.management.remote.JMXConnectorServer; +import javax.management.remote.JMXConnectorServerFactory; +import javax.management.remote.JMXServiceURL; + +import java.lang.management.ManagementFactory; +import java.net.ServerSocket; +import java.rmi.registry.LocateRegistry; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class JmxToolTest { + private final ToolsTestUtils.MockExitProcedure exitProcedure = new ToolsTestUtils.MockExitProcedure(); + + private static JMXConnectorServer jmxAgent; + private static String jmxUrl; + + @BeforeAll + public static void beforeAll() throws Exception { + int port = findRandomOpenPortOnAllLocalInterfaces(); + jmxAgent = startJmxAgent(port); + jmxUrl = String.format("service:jmx:rmi:///jndi/rmi://:%d/jmxrmi", port); + } + + @AfterAll + public static void afterAll() throws Exception { + jmxAgent.stop(); + } + + @BeforeEach + public void beforeEach() { + Exit.setExitProcedure(exitProcedure); + } + + @AfterEach + public void afterEach() { + Exit.resetExitProcedure(); + } + + @Test + public void kafkaVersion() { + String out = executeAndGetOut("--version"); + assertNormalExit(); + assertEquals(AppInfoParser.getVersion(), out); Review Comment: Ok, we reproduced the issue and I'll take your suggestion. Thanks. -- 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