kafka-testing | Test examples of kafka-clients : unit integration | Pub Sub library
kandi X-RAY | kafka-testing Summary
kandi X-RAY | kafka-testing Summary
Test examples of kafka-clients: unit, integration, end-to-end
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Start the downloader .
- Downloads a file from an URL
kafka-testing Key Features
kafka-testing Examples and Code Snippets
Community Discussions
Trending Discussions on kafka-testing
QUESTION
I've written a basic spring boot service that consumes some data via rest API and publishes it to rabbitmq and kafka.
To test the service class handling kafka producing, I followed this guide: https://www.baeldung.com/spring-boot-kafka-testing
In isolation, the test (KafkaMessagingServiceImplTest) works perfectly both in intellij idea and via mvn on the command line. Running all project tests in idea works fine. However, when I run all project tests via maven on the command line, this test fails with an NPE when trying to make the assertion on the payload String.
I've narrowed down the location of the root problem to another test class (AppPropertiesTest) which is solely testing my AppProperties component (which is a component I use to pull config from application.properties in a tidy way). When, and only when, the tests within that test class are run alongside the failing test using 'mvn clean install' in project root, does the NPE show up. Commenting out the tests in this class or annotating it with @DirtiesContext fixes the problem. Apparently something loaded into the spring context by this test class causes an issue with the timing/order of events/countdownlatch in the other test. Of course, I don't want to use @DirtiesContext as it can lead to a much slower build as the project increases in complexity. It also does not explain the problem.. and I can't handle that :)
AppPropertiesTest uses constructor injection to inject the AppProperties component. It also extends a abstract class 'GenericServiceTest' which is annotated by:
...ANSWER
Answered 2021-Apr-21 at 18:25The problem is that TestListener
is a @Component
so it is being added twice - the record is going to the other instance.
I added more debugging to verify the getter is called on a different instance.
QUESTION
I'm trying to figure out Spring Kafka. While following reference I found error in this example. There is no brokerListProperty()
method in EmbeddedKafkaRule
class. How should I refactor the code to make it work?
Code from link above:
...ANSWER
Answered 2020-Feb-17 at 13:53You can add brokerListProperty like that using KafkaTestUtils
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install kafka-testing
You can use kafka-testing like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the kafka-testing component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page