Hi Romain,
4 jan 2014 kl. 02:23 skrev Romain Gilles <[email protected]>:
> Hi all,
> I'm a beginner in akka. And I found it great so first of all thank you for
> this great job!
> I'm would like to test my actor in Java and I would like to use the unit test
> approach as describe in the documentation. Therefore I'm using the
> TestActorRef.create(...) method to create my Actor under testing.
> But unfortunately this actor create child actor for its context:
> getContext().actorOf(...).
> I the second case the actor creation does not use the Calling thread
> dispatcher strategy.
> Is there a way to make this strategy global for all actor creation? For the
> moment I use a workaround by delegating the creation of the actor to a third
> component that I switch the implementation for the test cases.
There are two ways to achieve that: you can use
.withDispatcher(context.props.dispatcher) when creating the child, or you can
use a configuration file in your tests (typically
src/test/resources/application.conf) which configures the
CallingThreadDispatcher for "/*/childName" if the children are named uniformly;
otherwise you can add the deployment section to the configuration you use when
creating the ActorSystem in your test:
final Config config = ConfigFactory.parseString(
" akka.actor.deployment {\n" +
" /*/* {\n" +
" dispatcher = \"akka.test.calling-thread-dispatcher\"\n" +
" }}");
final ActorSystem system = ActorSystem.create("MyTest",
config.withFallback(ConfigFactory.load()));
Regards,
Roland
>
> Thanks in advance,
>
> Romain.
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/groups/opt_out.
Dr. Roland Kuhn
Akka Tech Lead
Typesafe – Reactive apps on the JVM.
twitter: @rolandkuhn
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.