{"id":25776868,"url":"https://github.com/charithe/kafka-junit","last_synced_at":"2026-02-05T14:16:27.619Z","repository":{"id":28341640,"uuid":"31855086","full_name":"charithe/kafka-junit","owner":"charithe","description":"JUnit rule for spinning up a Kafka broker","archived":false,"fork":false,"pushed_at":"2024-11-19T18:11:50.000Z","size":264,"stargazers_count":104,"open_issues_count":3,"forks_count":46,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-14T14:06:38.248Z","etag":null,"topics":["java","junit","junit-rule","kafka"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charithe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-03-08T15:41:17.000Z","updated_at":"2025-01-03T21:44:28.000Z","dependencies_parsed_at":"2025-02-27T06:07:03.789Z","dependency_job_id":"d8540b65-ced3-4b82-b498-88482f40d360","html_url":"https://github.com/charithe/kafka-junit","commit_stats":null,"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"purl":"pkg:github/charithe/kafka-junit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charithe%2Fkafka-junit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charithe%2Fkafka-junit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charithe%2Fkafka-junit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charithe%2Fkafka-junit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charithe","download_url":"https://codeload.github.com/charithe/kafka-junit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charithe%2Fkafka-junit/sbom","scorecard":{"id":274157,"data":{"date":"2025-08-11","repo":{"name":"github.com/charithe/kafka-junit","commit":"2b4d723020643923e54264d5f1af4e607719ac72"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":0,"reason":"Found 2/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/charithe/kafka-junit/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/charithe/kafka-junit/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/charithe/kafka-junit/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/charithe/kafka-junit/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/charithe/kafka-junit/release.yml/master?enable=pin","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 9 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"12 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-h46c-h94j-95f3","Warn: Project is vulnerable to: GHSA-wxr5-93ph-8wr9","Warn: Project is vulnerable to: GHSA-389x-839f-4rhx","Warn: Project is vulnerable to: GHSA-xq3w-v528-46rv","Warn: Project is vulnerable to: GHSA-6mjq-h674-j845","Warn: Project is vulnerable to: GHSA-2x2g-32r7-p4x8","Warn: Project is vulnerable to: GHSA-vgq5-3255-v292","Warn: Project is vulnerable to: GHSA-79vv-vp32-gpp7","Warn: Project is vulnerable to: GHSA-p7c9-8xx8-h74f","Warn: Project is vulnerable to: GHSA-7286-pgfv-vxvh","Warn: Project is vulnerable to: GHSA-r978-9m6m-6gm6","Warn: Project is vulnerable to: GHSA-6qvw-249j-h44c"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T14:03:26.009Z","repository_id":28341640,"created_at":"2025-08-17T14:03:26.009Z","updated_at":"2025-08-17T14:03:26.009Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29123675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T14:05:12.718Z","status":"ssl_error","status_checked_at":"2026-02-05T14:03:53.078Z","response_time":65,"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":["java","junit","junit-rule","kafka"],"created_at":"2025-02-27T06:01:32.589Z","updated_at":"2026-02-05T14:16:27.603Z","avatar_url":"https://github.com/charithe.png","language":"Java","readme":"Kafka JUnit [![Build Status](https://travis-ci.org/charithe/kafka-junit.svg?branch=master)](https://travis-ci.org/charithe/kafka-junit) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.charithe/kafka-junit/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.charithe/kafka-junit)\n===========\n\nKafka Junit provides helpers for starting and tearing down a Kafka broker during tests.\n\n\n**Please note that version 3.x.x drops Java 7 support and contains breaking API changes.**\n\n\u003cdetails\u003e\n    \u003csummary\u003eVersion support matrix\u003c/summary\u003e\n\n| Version | Kafka Version                               |\n|---------|---------------------------------------------|\n| 1.6     | 0.8.2.1                                     |\n| 1.7     | 0.8.2.2                                     |\n| 1.8     | 0.9.0.0                                     |\n| 2.3     | 0.9.0.1                                     |\n| 2.4     | 0.10.0.0                                    |\n| 2.5     | 0.10.0.1                                    |\n| 3.0.0   | 0.10.0.1                                    |\n| 3.0.1   | 0.10.0.1                                    |\n| 3.0.2   | 0.10.1.1                                    |\n| 3.0.3   | 0.10.2.0                                    |\n| 3.0.4   | 0.10.2.1                                    |\n| 3.1.0   | 0.11.0.0                                    |\n| 3.1.1   | 0.11.0.1                                    |\n| 4.0.0   | 1.0.0                                       |\n| 4.1.0   | 1.0.0 (Adds support for both Junit 4 and 5) |\n| 4.1.1   | 1.1.0                                       |\n| 4.1.2   | 2.0.0                                       |\n| 4.1.3   | 2.1.0                                       |\n| 4.1.4   | 2.1.1                                       |\n| 4.1.5   | 2.2.0                                       |\n| 4.1.6   | 2.3.0                                       |\n| 4.1.7   | 2.4.0                                       |\n| 4.1.8   | 2.4.1                                       |\n| 4.1.9   | 2.5.0                                       |\n| 4.1.10  | 2.6.0                                       |\n| 4.1.11  | 2.6.0 (Scala 2.13)                          |\n| 4.2.0   | 2.8.0                                       |\n| 4.2.1   | 3.0.0                                       |\n| 4.2.2   | 3.2.0                                       |\n| 4.2.3   | 3.2.1                                       |\n| 4.2.4   | 3.4.0                                       |\n| 4.2.5   | 3.5.0                                       |\n| 4.2.6   | 3.5.0 (Security update)                     |\n| 4.2.7   | 3.5.0 (Security update)                     |\n| 4.2.10  | 3.6.0                                       |\n\n\u003c/details\u003e\n\nInstallation\n-------------\n\nReleases are available on Maven Central.\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.charithe/kafka-junit/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.charithe/kafka-junit)\n\n\nSnapshot versions containing builds from the latest `master` are available in the Sonatype snapshots repo.\n\nJavadocs\n--------\n\n\u003chttp://charithe.github.io/kafka-junit/\u003e\n\nUsage\n------\n\n### JUnit 4\n\nCreate an instance of the rule in your test class and annotate it with `@Rule`. This will start and stop the\nbroker between each test invocation.\n\n ```java\n @Rule\n public KafkaJunitRule kafkaRule = new KafkaJunitRule(EphemeralKafkaBroker.create());\n ```\n\n\n To spin up the broker at the beginning of a test suite and tear it down at the end, use `@ClassRule`.\n\n ```java\n @ClassRule\n public static KafkaJunitRule kafkaRule = new KafkaJunitRule(EphemeralKafkaBroker.create());\n ```\n\n\n\n`kafkaRule` can be referenced from within your test methods to obtain information about the Kafka broker.\n\n```java\n@Test\npublic void testSomething(){\n    // Convenience methods to produce and consume messages\n    kafkaRule.helper().produceStrings(\"my-test-topic\", \"a\", \"b\", \"c\", \"d\", \"e\");\n    List\u003cString\u003e result = kafkaRule.helper().consumeStrings(\"my-test-topic\", 5).get();\n\n    // or use the built-in producers and consumers\n    KafkaProducer\u003cString, String\u003e producer = kafkaRule.helper().createStringProducer();\n\n    KafkaConsumer\u003cString, String\u003e consumer = kafkaRule.helper().createStringConsumer();\n\n    // Alternatively, the Zookeeper connection String and the broker port can be retrieved to generate your own config\n    String zkConnStr = kafkaRule.helper().zookeeperConnectionString();\n    int brokerPort = kafkaRule.helper().kafkaPort();\n}\n```\n\n`EphemeralKafkaBroker` contains the core logic used by the JUnit rule and can be used independently.\n\n`KafkaHelper` contains a bunch of convenience methods to work with the `EphemeralKafkaBroker`\n\n### JUnit 5\n\nJUnit 5 does not have support for Rules, but instead uses the new [JUnit 5 Extension Model](http://junit.org/junit5/docs/current/user-guide/#extensions).\n\nSo if you are using JUnit 5 you can use `KafkaJunitExtension` which provides a kafka broker that is started and stopped for each test.\n\nThe extension is configured using the optional class annotation `@KafkaJunitExtensionConfig` and provides\ndependency injection for constructors and methods for the classes `KafkaHelper` and `EphemeralKafkaBroker`\n\n```java\n@ExtendWith(KafkaJunitExtension.class)\n@KafkaJunitExtensionConfig(startupMode = StartupMode.WAIT_FOR_STARTUP)\nclass MyTestClass {\n\n    @Test\n    void testSomething(KafkaHelper kafkaHelper) throws ExecutionException, InterruptedException {\n        // Convenience methods to produce and consume messages\n        kafkaHelper.produceStrings(\"my-test-topic\", \"a\", \"b\", \"c\", \"d\", \"e\");\n        List\u003cString\u003e result = kafkaHelper.consumeStrings(\"my-test-topic\", 5).get();\n        assertThat(result).containsExactlyInAnyOrder(\"a\", \"b\", \"c\", \"d\", \"e\");\n\n        // or use the built-in producers and consumers\n        KafkaProducer\u003cString, String\u003e producer = kafkaHelper.createStringProducer();\n\n        KafkaConsumer\u003cString, String\u003e consumer = kafkaHelper.createStringConsumer();\n\n        // Alternatively, the Zookeeper connection String and the broker port can be retrieved to generate your own config\n        String zkConnStr = kafkaHelper.zookeeperConnectionString();\n        int brokerPort = kafkaHelper.kafkaPort();\n    }\n}\n```\n\nRefer to [Javadocs](http://charithe.github.io/kafka-junit/) and unit tests for more usage examples.\n","funding_links":[],"categories":["测试"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharithe%2Fkafka-junit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharithe%2Fkafka-junit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharithe%2Fkafka-junit/lists"}