{"id":22152147,"url":"https://github.com/findinpath/kafkalistener-e2e-test","last_synced_at":"2026-03-09T04:31:01.690Z","repository":{"id":54426967,"uuid":"222551496","full_name":"findinpath/kafkalistener-e2e-test","owner":"findinpath","description":"Showcase for end-to-end-testing on spring-kafka's KafkaListener","archived":false,"fork":false,"pushed_at":"2022-11-15T23:53:03.000Z","size":21,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-12T14:33:03.860Z","etag":null,"topics":["end-to-end-testing","kafka","spring-kafka","testcontainers"],"latest_commit_sha":null,"homepage":"https://www.findinpath.com/kafkalistener-end-to-end-tests/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/findinpath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-18T21:50:55.000Z","updated_at":"2024-06-09T14:43:03.000Z","dependencies_parsed_at":"2022-08-13T15:20:24.672Z","dependency_job_id":null,"html_url":"https://github.com/findinpath/kafkalistener-e2e-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/findinpath/kafkalistener-e2e-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fkafkalistener-e2e-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fkafkalistener-e2e-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fkafkalistener-e2e-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fkafkalistener-e2e-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/findinpath","download_url":"https://codeload.github.com/findinpath/kafkalistener-e2e-test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/findinpath%2Fkafkalistener-e2e-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30283411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["end-to-end-testing","kafka","spring-kafka","testcontainers"],"created_at":"2024-12-02T00:47:25.776Z","updated_at":"2026-03-09T04:31:01.666Z","avatar_url":"https://github.com/findinpath.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"End to end tests for spring KafkaListener\n=========================================\n\nThis project showcases how the \n[KafkaListener](https://docs.spring.io/spring-kafka/api/org/springframework/kafka/annotation/KafkaListener.html)\nbelonging to the [spring-kafka](https://spring.io/projects/spring-kafka) library can\nbe tested in an end-to-end fashion.\n\nThe [spring-kafka](https://spring.io/projects/spring-kafka) comes with a few testing \nutilities, but it doesn't provide any utilities for testing the methods\nannotated with the [KafkaListener](https://docs.spring.io/spring-kafka/api/org/springframework/kafka/annotation/KafkaListener.html)\nannotation. Moreover, it makes use of an embedded Apache Kafka broker, instead of\ndockerized Apache Kafka container image artifacts. \n\nThis project makes use of [testcontainers](https://www.testcontainers.org/) library\nfor spawning before the tests a complete [Confluent](https://www.confluent.io/) ecosystem\nof [docker](https://www.docker.com/) container images for artifacts related to Apache Kafka:\n\n- Apache Kafka\n- Apache Zookeeper\n- Confluent Schema Registry\n\nBy using versions for the container images that correspond to the productive Apache Kafka\necosystem, there is simulated an environment which is very close to the one running in the \nproduction. This particularity gives even more relevance to the integration/ end-to-end tests\nfor the kafka listener functionality.  \n\nBy having the ability to perform end-to-end tests in a throwaway dockerized environment \nthere can be executed with a high certainty common scenarios that the kafka listener service \nis supposed to handle as part of its contract.\n\nOnce the Apache Kafka ecosystem is up and running, the topics necessary for the end-to-end\ntests are created and also the [AVRO](https://avro.apache.org/) types are registered \nto Confluent Schema Registry docker container. \nAfter this setup, the rest of the spring beans from Spring's dependency\ninjection container (including the kafka listeners) are initialized and therefor we can\nexecute end-to-end tests on top of them.\n\n\nThis proof of concept project offers two end-to-end sample tests:\n\n- `com.findinpath.kafka.listener.UserBookmarkEventAvroListenerTest` : for \ntesting the consumption of messages serialized in [AVRO](https://avro.apache.org/) format\n- `com.findinpath.kafka.listener.UserBookmarkEventJsonListenerTest` : for \ntesting the consumption of messages serialized in `JSON` format \n\nRun the command\n\n```\nmvn clean install\n```\n\nfor executing the tests from this project.\n \n \n## Limitations\n\nCompared to the tests in which the tests in which the \n[KafkaConsumer](https://kafka.apache.org/23/javadoc/index.html?org/apache/kafka/clients/consumer/KafkaConsumer.html)\ncan be manipulated directly in order to be able to reset the consumer offset\nafter each test, [spring-kafka](https://spring.io/projects/spring-kafka) hides the \nconsumer instance inside the class `org.springframework.kafka.listener.KafkaMessageListenerContainer.listenerConsumer`\nwith a `private` access. \nEven with extra motivation, when accessing the private field via Java Reflection,\nin order to reset its offset, the operations on it will fail because multi-threaded\naccess on the consumer is not supported (see `org.apache.kafka.clients.consumer.KafkaConsumer.acquire` method).\n\n\nBut even with the limitation of not being able to reset the consumer offset,\nit is still quite useful to ensure the fact that the right service is being called to handle\nKafka message sent over the topic (otherwise said, regression test).\n\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffindinpath%2Fkafkalistener-e2e-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffindinpath%2Fkafkalistener-e2e-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffindinpath%2Fkafkalistener-e2e-test/lists"}