Reputation: 21
I was trying the JUnit test class https://github.com/spring-cloud/spring-cloud-stream/blob/main/binders/kafka-binder/spring-cloud-stream-binder-kafka-streams/src/test/java/org/springframework/cloud/stream/binder/kafka/streams/function/KafkaStreamsBinderWordCountBranchesFunctionTests.java I downloaded the code and tried running the above JUnit Test. This uses EmbeddedKafka. The test case works fine in VisualStudio code but it fails in IntelliJ Community Edition with following error
`java.lang.NullPointerException: Cannot invoke "org.springframework.kafka.test.EmbeddedKafkaBroker.getBrokersAsString()" because "embeddedKafka" is null
at org.springframework.kafka.test.utils.KafkaTestUtils.consumerProps(KafkaTestUtils.java:82)
at org.springframework.cloud.stream.binder.kafka.streams.function.KafkaStreamsBinderWordCountBranchesFunctionTests.setUp(KafkaStreamsBinderWordCountBranchesFunctionTests.java:64)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Suppressed: java.lang.NullPointerException: Cannot invoke "org.apache.kafka.clients.consumer.Consumer.close()" because "org.springframework.cloud.stream.binder.kafka.streams.function.KafkaStreamsBinderWordCountBranchesFunctionTests.consumer" is null
at org.springframework.cloud.stream.binder.kafka.streams.function.KafkaStreamsBinderWordCountBranchesFunctionTests.tearDown(KafkaStreamsBinderWordCountBranchesFunctionTests.java:74)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092)
... 1 more`
It should work in all IDE. Please help.
Upvotes: 0
Views: 212
Reputation: 21
Found one weird observation, if the individual tests are run then it fails, but if the Test is run at class level then it works in IntelliJ as well, which is different than Visual Studio code, where it works at both class and individual test level. This issue is no longer a broker and can be closed.
Upvotes: 0