Re: [akka-user] Java : How should Futures be handled when Unit testing?

2015-04-09 Thread Viktor Klang
Does this help? http://christopher-batey.blogspot.se/2014/02/testing-scala-futures-with-scalatest-20.html 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

Re: [akka-user] Java : How should Futures be handled when Unit testing?

2015-04-09 Thread Akka Team
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

Re: [akka-user] Java : How should Futures be handled when Unit testing?

2015-04-09 Thread Adam Daines
Thank you both for the quick and helpful responses! Our issue is now resolved :) Thanks. On Thursday, April 9, 2015 at 1:01:24 PM UTC+1, √ wrote: 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

Re: [akka-user] Java : How should Futures be handled when Unit testing?

2015-04-09 Thread Viktor Klang
Hi Adam, I generally recommend against using onComplete, onSuccess and onFailure for that reason, instead use map/flatMap/andThen/recover/recoverWith/transform On Thu, Apr 9, 2015 at 4:14 PM, Adam Daines dainesa...@gmail.com wrote: Hi again, At first it had appeared that the issue was fully

[akka-user] Java : How should Futures be handled when Unit testing?

2015-04-09 Thread Adam Daines
Hi all, I've got a question in relation to the unit testing of a piece of non actor code that produces a FutureActorRef 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

Re: [akka-user] Java : How should Futures be handled when Unit testing?

2015-04-09 Thread Viktor Klang
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?

Re: [akka-user] Java : How should Futures be handled when Unit testing?

2015-04-09 Thread Adam Daines
Hi again, At first it had appeared that the issue was fully resolved but the test I had written began to fail again intermittently. It appears that taking the approach Endre suggested does not quite work as I had expected. It appears that the Await triggers and unblocks at the moment that