{"id":37024375,"url":"https://github.com/zapodot/akka-test-junit","last_synced_at":"2026-01-14T02:56:51.954Z","repository":{"id":17819074,"uuid":"20717641","full_name":"zapodot/akka-test-junit","owner":"zapodot","description":"JUnit @Rule for easy setup of Akka ActorSystem for tests","archived":true,"fork":false,"pushed_at":"2022-08-16T19:00:23.000Z","size":103,"stargazers_count":2,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-11T16:59:22.868Z","etag":null,"topics":["actors","akka","java","junit","junit-rule"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zapodot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-11T08:15:17.000Z","updated_at":"2023-01-27T22:14:49.000Z","dependencies_parsed_at":"2022-07-26T02:19:34.052Z","dependency_job_id":null,"html_url":"https://github.com/zapodot/akka-test-junit","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/zapodot/akka-test-junit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapodot%2Fakka-test-junit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapodot%2Fakka-test-junit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapodot%2Fakka-test-junit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapodot%2Fakka-test-junit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zapodot","download_url":"https://codeload.github.com/zapodot/akka-test-junit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapodot%2Fakka-test-junit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["actors","akka","java","junit","junit-rule"],"created_at":"2026-01-14T02:56:49.725Z","updated_at":"2026-01-14T02:56:51.938Z","avatar_url":"https://github.com/zapodot.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Akka Test JUNIT \n__Not maintained any more__\n\n[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=zapodot\u0026url=https://github.com/zapodot/akka-test-junit\u0026title=akka-test-junit\u0026language=\u0026tags=github\u0026category=software)\n[![Build Status](https://travis-ci.org/zapodot/akka-test-junit.svg?branch=master)](https://travis-ci.org/zapodot/akka-test-junit)\n[![Coverage Status](https://img.shields.io/coveralls/zapodot/akka-test-junit.svg)](https://coveralls.io/r/zapodot/akka-test-junit)\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.zapodot/akka-test-junit/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.zapodot/akka-test-junit)\n[![License: Apache 2](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n[![Libraries.io for GitHub](https://img.shields.io/librariesio/github/zapodot/akka-test-junit.svg)](https://libraries.io/github/zapodot/akka-test-junit)\n\nProvides a JUnit rule for controlled testing of [Akka](http://akka.io) actors using [JUnit](http://junit.org).\n\nTested with Akka 2.5.11 and JUnit 4.12. This tool, including the source code is made available under an Apache 2.0 license.\n\n## Add dependency\nAs this library is distributed through the Sonatype OSS repository, it should be easy to add it to your project\n\n### Maven\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.zapodot\u003c/groupId\u003e\n    \u003cartifactId\u003eakka-test-junit\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.0\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n### SBT\n```scala\nlibraryDependencies += \"org.zapodot\" % \"akka-test-junit\" % \"2.0.0\"\n```\n\n### Gradle\n```groovy\ncompile 'org.zapodot:akka-test-junit:2.0.0'\n```\n\n\n## Example\nThe ActorSystemRule may be used either as a @Rule (invoked around test methods) or as a @ClassRule (invoked before/after the TestClass)\n\n### As a @Rule\n```java\npublic class SimpleAkkaTest {\n\n    @Rule\n    public ActorSystemRule actorSystemRule = new ActorSystemRuleBuilder().setName(getClass().getSimpleName()).build();\n\n    @Test\n    public void testRuleUsingASingleActor()  {\n        final TestActorRef\u003cSimpleActor\u003e actorTestActorRef = TestActorRef.create(actorSystemRule.system(),\n                                                                          Props.create(SimpleActor.class));\n        final String message = \"test\";\n        actorTestActorRef.tell(message, ActorRef.noSender());\n        assertEquals(message, actorTestActorRef.underlyingActor().received.peek());\n        \n        // Use the testKit() to get an instance of JavaTestKit directly\n        // In this example EchoActor simply sends the message to the designated sender actor\n        final JavaTestKit testKit = actorSystemRule.testKit();\n        final Props simpleActorProps = Props.create(EchoActor.class);\n        final ActorRef simpleActor = actorSystemRule.system().actorOf(simpleActorProps);\n        simpleActor.tell(\"A great message\", testKit.getTestActor()); // Use testActor as sender\n        testKit.expectMsgEquals(FiniteDuration.apply(1L, TimeUnit.SECONDS), \"A great message\");\n           \n\n    }\n\n        \n}\n```\n\n### As a @ClassRule\n```java\npublic class SimpleAkkaTest {\n\n    // ClassRules must be instantiated as public static fields on the test class\n    @ClassRule\n    public static ActorSystemRule actorSystemRule = ActorSystemRule.builder().setName(getClass().getSimpleName()).build();\n\n    @Test\n    public void testRuleUsingASingleActor() {\n        final TestActorRef\u003cSimpleActor\u003e actorTestActorRef = TestActorRef.create(actorSystemRule.system(),\n                                                                          Props.create(SimpleActor.class));\n        final String message = \"test\";\n        actorTestActorRef.tell(message, ActorRef.noSender());\n        assertEquals(message, actorTestActorRef.underlyingActor().received.peek());\n\n    }\n    \n    @Test\n    public void testAnotherThing() {\n        final TestActorRef\u003cSimpleActor\u003e actorTestActorRef = TestActorRef.create(actorSystemRule.system(),\n                                                                                  Props.create(SimpleActor.class));\n        // Will use the same actorSystem instance as in the previous test. NB! Be aware of JUnit's ordering rules                                                                         \n    }\n}\n```\n### With event logging enabled (version \u003e= 1.1.0)\n```java\n@Rule\npublic ActorSystemRule actorSystemWithEventLoggerEnabled = ActorSystemRule.builder()\n                                                        .enableEventLogging()\n                                                        .setName(getClass().getSimpleName())\n                                                        .build();\n```\n\n### With event test listener enabled(version \u003e= 1.1.0)\n```java\n@Rule\npublic ActorSystemRule actorSystemRule = ActorSystemRule.builder()\n                                                       .setName(getClass().getSimpleName())\n                                                       .setConfigFromString(\"akka.loglevel = DEBUG\")\n                                                       .enableEventTestListener()\n                                                       .build();\n\n@Test\npublic void testEventFilterEnabled() throws Exception {\n   new JavaTestKit(actorSystemRule.system()) {{\n       final ActorRef loggingActor = getSystem().actorOf(Props.create(LoggingActor.class), \"loggingActor\");\n       Integer result = new EventFilter\u003cInteger\u003e(Logging.Info.class) {\n           @Override\n           protected Integer run() {\n\n               loggingActor.tell(LoggingActor.INFO_MESSAGE, ActorRef.noSender());\n               return 1;\n           }\n       }.from(loggingActor.path().toString()).occurrences(1).exec();\n       assertEquals(1, result.intValue());\n   }};\n\n}\n```\n\n### With custom configuration (version \u003e= 1.1.0)\n```java\npublic class SimpleAkkaTest {\n\n    @Rule\n    public ActorSystemRule actorSystemRule = ActorSystemRule.builder().setName(\"test-system\").setConfigFromString(\n            \"akka {\\n\"\n            + \"    loggers = [\\\"akka.event.slf4j.Slf4jLogger\\\"]\\n\"\n            + \"    loglevel = DEBUG\\n\"\n            + \"}\").build();\n\n    @Test\n    public void testRuleUsingASingleActor() throws Exception {\n        final TestActorRef\u003cSimpleActor\u003e actorTestActorRef = TestActorRef.create(actorSystemRule.system(),\n                                                                          Props.create(SimpleActor.class));\n        final String message = \"test\";\n        actorTestActorRef.tell(message, ActorRef.noSender());\n        assertEquals(message, actorTestActorRef.underlyingActor().received.peek());\n\n    }\n}\n```\n## Changelog\n* Version 2.0.0: Akka 2.5.0 support - support for previous versions are dropped. Java baseline is 1.8\n* Version 1.3.0: Verifies that the ActorSystem is indeed properly shutdown. Allows a shutdown timeout to be set\n* Version 1.2.0: Add a new testKit() method that to create a JavaTestKit\n* Version 1.1.1: Fixed a bug in ActorSystemRuleBuilder that replaced the configuration instead of added to it\n* Version 1.1: Added the ActorSystemRuleBuilder and the ability to specify configuration and/or enable logging for the actor system\n* Version 1.0: First release\n\n## Limitations\nA few words of caution when using @ClassRule:\n* JUnit might not run the tests in the order you predicted. Check [JUnit execution ordering](//github.com/junit-team/junit/wiki/Test-execution-order).\n* If you name your actors be aware the Akka expects actor names to be unique within the same actor system\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapodot%2Fakka-test-junit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzapodot%2Fakka-test-junit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapodot%2Fakka-test-junit/lists"}