Ouch, nice catch, now we've covered both the question and the alternative
(Scala) :)

On Thu, Apr 9, 2015 at 1:59 PM, Akka Team <akka.offic...@gmail.com> wrote:

>
>
> On Thu, Apr 9, 2015 at 1:33 PM, Viktor Klang <viktor.kl...@gmail.com>
> wrote:
>
>> Does this help?
>>
>>
>> http://christopher-batey.blogspot.se/2014/02/testing-scala-futures-with-scalatest-20.html
>>
>
> That is for scala though. We usually use scala.concurrent.Await which can
> be used like this
>
>   assert(Await.result(myFuture, timeoutDuration) == xyz)
>
> This will block the test and wait until the future becomes ready. If the
> future completes then the assertion will run. If the future fails, then
> Await.result() will throw the exception. If the future does not complete
> during the time defined in timeoutDuration, then it will throw A
> TimeoutException.
>
> -Endre
>
>
>>
>> On Thu, Apr 9, 2015 at 1:27 PM, Adam Daines <dainesa...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I've got a question in relation to the unit testing of a piece of non
>>> actor code that produces a Future<ActorRef> via performing an
>>> actorSelection().resolveOne on the ActorSystem.
>>>
>>> Within the Future.onFailure() a value is being set that I would like to
>>> test but the Future is making use of the ActorSystem.dispatcher() which is
>>> therefore causing asynchronicity issues when attempting to Assert that the
>>> value has been set as expected.
>>>
>>> I am currently performing a Thread.sleep() within the Unit test to
>>> provide enough time for the value to have been set but this is far from
>>> ideal!
>>>
>>> What is the best way to go about testing this type of code without
>>> having to sleep and wait? Is it possible to override the dispatcher that
>>> the ActorSystem returns with the CallingThreadDispatcher?
>>>
>>> Thanks.
>>>
>>> --
>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>> >>>>>>>>>> Check the FAQ:
>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
>>> To post to this group, send email to akka-user@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Cheers,
>> √
>>
>> --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ:
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
>> To post to this group, send email to akka-user@googlegroups.com.
>> Visit this group at http://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Akka Team
> Typesafe - Reactive apps on the JVM
> Blog: letitcrash.com
> Twitter: @akkateam
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
> To post to this group, send email to akka-user@googlegroups.com.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Cheers,
√

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to