Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
Add preliminary support for Akka 2.5 as described in #6
Browse files Browse the repository at this point in the history
  • Loading branch information
zapodot committed Apr 4, 2017
1 parent e44b8c8 commit 1be296e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.12</junit.version>
<akka.version>2.3.15</akka.version>
<slf4j.version>1.7.21</slf4j.version>
<akka.version>2.5.0-RC2</akka.version>
<slf4j.version>1.7.25</slf4j.version>
<akka-persistence-inmemory.version>0.2.1</akka-persistence-inmemory.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<maven-javadoc-plugin.version>2.10.2</maven-javadoc-plugin.version>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/zapodot/akka/junit/ActorSystemRule.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.zapodot.akka.junit;

import akka.actor.ActorSystem;
import akka.testkit.JavaTestKit;
import akka.testkit.javadsl.TestKit;
import org.junit.rules.TestRule;

/**
Expand Down Expand Up @@ -38,10 +38,10 @@ public interface ActorSystemRule extends TestRule {
ActorSystem system();

/**
* Convienience method that provides easy access to a {@link JavaTestKit} instance.
* Convienience method that provides easy access to a {@link TestKit} instance.
*
* @return the {@link JavaTestKit} instance that was created before the test ran
* @return the {@link TestKit} instance that was created before the test ran
*/
JavaTestKit testKit();
TestKit testKit();

}
14 changes: 6 additions & 8 deletions src/main/java/org/zapodot/akka/junit/ActorSystemRuleImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UnhandledMessage;
import akka.testkit.JavaTestKit;
import akka.testkit.TestActorRef;
import akka.testkit.javadsl.TestKit;
import com.typesafe.config.Config;
import org.junit.rules.ExternalResource;
import org.slf4j.Logger;
Expand All @@ -29,7 +29,7 @@ public class ActorSystemRuleImpl extends ExternalResource implements ActorSystem
private ActorSystem actorSystem;
private Config config = null;
private TestActorRef<ConsumingActor> unhandledMessagesConsumer;
private JavaTestKit javaTestKit;
private TestKit javaTestKit;
private final long shutdownTimeoutSeconds;


Expand Down Expand Up @@ -90,7 +90,7 @@ public ActorSystem system() {
}

@Override
public JavaTestKit testKit() {
public TestKit testKit() {
return javaTestKit;
}

Expand All @@ -101,18 +101,16 @@ protected void before() throws Throwable {

unhandledMessagesConsumer = TestActorRef.create(actorSystem, Props.create(ConsumingActor.class), "unhandledMessagesConsumer");
actorSystem.eventStream().subscribe(unhandledMessagesConsumer, UnhandledMessage.class);
javaTestKit = new JavaTestKit(actorSystem);
javaTestKit = new TestKit(actorSystem);

}

@Override
protected void after() {

javaTestKit = null;
if (!actorSystem.isTerminated()) {
LOGGER.debug("Shutting down ActorSystem \"{}\"", name);
JavaTestKit.shutdownActorSystem(actorSystem, Duration.apply(shutdownTimeoutSeconds, TimeUnit.SECONDS), true);
}
LOGGER.debug("Shutting down ActorSystem \"{}\"", name);
TestKit.shutdownActorSystem(actorSystem, Duration.apply(shutdownTimeoutSeconds, TimeUnit.SECONDS), true);
actorSystem = null;
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/org/zapodot/akka/junit/TestKitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.testkit.JavaTestKit;
import akka.testkit.javadsl.TestKit;
import org.junit.Rule;
import org.junit.Test;
import scala.concurrent.duration.FiniteDuration;
Expand Down Expand Up @@ -35,7 +35,7 @@ public void onReceive(final Object message) throws Exception {

@Test
public void testRule() throws Exception {
final JavaTestKit javaTestKit = testKitRule.testKit();
final TestKit javaTestKit = testKitRule.testKit();
final ActorRef testActor = javaTestKit.getTestActor();

final String message = "test";
Expand All @@ -48,7 +48,7 @@ public void testRule() throws Exception {
public void testRuleAsync() throws Exception {
final Props simpleActorProps = Props.create(SimpleActor.class);
final ActorRef simpleActorRef = testKitRule.system().actorOf(simpleActorProps);
final JavaTestKit testProbe = testKitRule.testKit();
final TestKit testProbe = testKitRule.testKit();

final String msg = "Hello AKKA";
simpleActorRef.tell(msg, testProbe.getTestActor());
Expand Down

0 comments on commit 1be296e

Please sign in to comment.