Questions tagged [akka-testkit]

Akka comes with a dedicated module akka-testkit for supporting tests at different levels.

140 questions
0
votes
1 answer

How should I test akka-streams RestartingSource usage

I'm working on an application that has a couple of long-running streams going, where it subscribes to data about a certain entity and processes that data. These streams should be up 24/7, so we needed to handle failures (network issues etc). For…
Mopper
  • 1,677
  • 2
  • 18
  • 41
0
votes
1 answer

Akka test - wait for actor initialization

case class FeatureFilter(s3Client: AmazonS3) extends Actor with ActorLogging { override def preStart(): Unit = { self ! Initialize } override def receive: Receive = { case Initialize => // long running operaton val…
Sumit Jha
  • 2,095
  • 2
  • 21
  • 36
0
votes
2 answers

how to get the value of a future in an Async way in scala test using akka test kit

i am using akka testkit and scalatests for running my test here is my code class MyTest extends (ActorSystem("testsystem")) /*with AsyncWordSpec*/ with ImplicitSender with AnyWordSpecLike with Matchers with BeforeAndAfterAll { "an actor test"…
swaheed
  • 3,671
  • 10
  • 42
  • 103
0
votes
1 answer

How to use TestKit to not process messages sent to Self

I'm trying to test an Actor. On one scenario I want to focus on how it processes a message. For various design reasons, I want to split up an action in to 2 separate distinct steps / messages for the same actor. Mainly, it is possible that the 2nd…
Andre
  • 754
  • 1
  • 10
  • 16
0
votes
1 answer

akka-http-testkit with akka-actor-testkit-typed

I am trying to test a TypedActor with akka-http and have issues while trying to create a Test case. For testing a TypedActor, I would write the following Spec... class MyServiceTestSpec extends ScalaTestWithActorTestKit with FlatSpecLike with…
Developer
  • 691
  • 8
  • 7
0
votes
1 answer

How to test for unhandled messages

I have an AKKA actor that currently throws an exception when receved n unhandled message. How do I write a test case to prove that this exception is thrown ? The following assertion fails expectMessageClass(MyException.class) I do see the exception…
user_mda
  • 18,148
  • 27
  • 82
  • 145
0
votes
1 answer

Testing message forwarding in akka.testkit.TestKit

I want to test the following scenario: Assume I have a parent actor, which creates two child actors like this. class A extends Actor { def getActorOf(props: Props) = { context.actorOf(props, props.clazz.getTypeName) } def receive: Receive…
Łukasz Rzeszotarski
  • 5,791
  • 6
  • 37
  • 68
0
votes
1 answer

TestProbe not receiving messages from RouteSpec

I'm having issues when trying to "mock" out an Actor behind a Route. I want to be able to override and simulate functionality at test time, and I think TestProbe is the correct way to approach this. However, I have not gotten a TestProbe to receive…
VolatileRig
  • 2,727
  • 6
  • 32
  • 44
0
votes
2 answers

How to create actor with parameterized constructor from testprobe

I am trying test to MyActor for sending a MessageB to itself on condition. MyActor takes setting as constructor parameter. Setting doesn't have setter cause it is intended to be immutable after creation. public class MyActor : ReceiveActor { …
invo
  • 81
  • 9
0
votes
1 answer

Testing delayed messages with the help of akka-testkit

There are two actors - ProducerActor and ConsumerActor. Producer has a scheduler which sends "Tick" message to itself each 2000 ms. After that the producer sends "Hello" message to consumer: class ProducerActor(consumer: ActorRef) extends Actor { …
John Mullins
  • 1,061
  • 4
  • 11
  • 38
0
votes
2 answers

How to Mock akka Actor for unit Test?

@Singleton class EventPublisher @Inject() (@Named("rabbit-mq-event-update-actor") rabbitControlActor: ActorRef) (implicit ctx: ExecutionContext) { def publish(event: Event): Unit = { logger.info("Publishing Event: {}", toJsObject(event),…
Arun Gupta
  • 810
  • 2
  • 9
  • 26
0
votes
1 answer

Akka Test TCP command failed

I am trying to write my first Akka test and going through the documentation. I was running the very first example of it and getting following error: [ERROR] [10/26/2017 14:08:55.371] [IngestionWorkerActorSpec-akka.actor.default-dispatcher-4]…
Explorer
  • 1,491
  • 4
  • 26
  • 67
0
votes
1 answer

Test code from Akka documentation runs strangely

I am learning test methods in the Akka actor model. I tried to run some code from the Akka documentation. When I run the following code, a confusing error occurs. I'm using JDK 1.8.121, macOS, and Scala 2.12. The code from the Akka…
jiexray
  • 325
  • 4
  • 13
0
votes
1 answer

akka and testkit. Can't get actor children

I have an actor with receive method: def receive: Actor.Receive = { case Tick => val child = context.system.actorOf(...) // create actor context.watch(child) child ! something case AskRunningJobs => …
Capacytron
  • 3,425
  • 6
  • 47
  • 80
0
votes
1 answer

Example of using EventFilter in java to test log messages

I can't find a working Java example of how to use the EventFilter functionality made available in the Akka TestKit. I want to assert that something was logged and while searching I arrived at this link in the…