rondagostino commented on a change in pull request #11503:
URL: https://github.com/apache/kafka/pull/11503#discussion_r752335041
##########
File path: core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala
##########
@@ -186,34 +186,31 @@ class KafkaConfigTest {
// listeners with duplicate port
props.put(KafkaConfig.ListenersProp,
"PLAINTEXT://localhost:9091,SSL://localhost:9091")
- var caught = assertThrows(classOf[IllegalArgumentException], () =>
KafkaConfig.fromProps(props))
- assertTrue(caught.getMessage.contains("Each listener must have a different
port"))
+ assertBadConfigContainingMessage(props, "Each listener must have a
different port")
// listeners with duplicate name
props.put(KafkaConfig.ListenersProp,
"PLAINTEXT://localhost:9091,PLAINTEXT://localhost:9092")
- caught = assertThrows(classOf[IllegalArgumentException], () =>
KafkaConfig.fromProps(props))
- assertTrue(caught.getMessage.contains("Each listener must have a different
name"))
+ assertBadConfigContainingMessage(props, "Each listener must have a
different name")
// advertised listeners can have duplicate ports
props.put(KafkaConfig.ListenerSecurityProtocolMapProp,
"HOST:SASL_SSL,LB:SASL_SSL")
props.put(KafkaConfig.InterBrokerListenerNameProp, "HOST")
props.put(KafkaConfig.ListenersProp,
"HOST://localhost:9091,LB://localhost:9092")
props.put(KafkaConfig.AdvertisedListenersProp,
"HOST://localhost:9091,LB://localhost:9091")
- assertTrue(isValidKafkaConfig(props))
+ KafkaConfig.fromProps(props)
Review comment:
Simply trying to create the config is better because if the config is
invalid we actually see the exception that caused it, which is much more
helpful than simply seeing that `true` was expected and we got `false` instead.
I made this change in many places below as well.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]