Testing Actors in Akka, the book

65 views
Skip to first unread message

Fabrizio Giudici

unread,
Sep 29, 2012, 2:24:02 PM9/29/12
to java...@googlegroups.com
Just seen the advertising by Manning of this book. Which would be quite
interesting for me, but it seems that examples are only in Scala - which
makes it useless for me. Is there any similar resource with examples in
Java? I'm doing more experiments with actors and I'd like to see a
structured approach to testing, to compare what I've done so far.

--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
fabrizio...@tidalwave.it
http://tidalwave.it - http://fabriziogiudici.it

Kevin Wright

unread,
Sep 29, 2012, 3:09:16 PM9/29/12
to java...@googlegroups.com

Akka's own documentation is rather good, and free, and has dedicated sections to cover all the relevant functionality via both the Scala and Java APIs.

Having said that (and my opinion may be seen as controversial here)...  You may find it easier to start learning the Scala API and then apply that understanding to Java.  Pattern matching and first-class functions are both very heavily used concepts and can be directly expressed in Scala, once you understand the "big picture" then Java's encoding of these ideas will be far less distracting from the core ideas.



--
You received this message because you are subscribed to the Google Groups "Java Posse" group.
To post to this group, send email to java...@googlegroups.com.
To unsubscribe from this group, send email to javaposse+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.

Fabrizio Giudici

unread,
Sep 29, 2012, 3:26:33 PM9/29/12
to java...@googlegroups.com, Kevin Wright
On Sat, 29 Sep 2012 21:09:16 +0200, Kevin Wright
<kev.lee...@gmail.com> wrote:

> Akka's own documentation is rather good, and free, and has dedicated
> sections to cover all the relevant functionality via both the Scala and
> Java APIs.
>
> Having said that (and my opinion may be seen as controversial here)...
> You
> may find it easier to start learning the Scala API and then apply that
> understanding to Java. Pattern matching and first-class functions are
> both
> very heavily used concepts and can be directly expressed in Scala, once
> you
> understand the "big picture" then Java's encoding of these ideas will be
> far less distracting from the core ideas.

I don't have problems with the Akka APIs (Java in my case), which I'm
already using - though still at an elementary level.
I'm searching for something specifically aimed at tests with agents. For
instance, in my studies so far I've ended up with writing a small message
recorder and the Hamcrest support for post-test assertions, as in some
tests I'm verifying that there's a specific exchange of messages. I bet
this is naive, due to the async nature of ages. What I need are agent
testing best practices, I suppose there are some out there...


--
Fabrizio Giudici - Java Architect @ Tidalwave s.a.s.
"We make Java work. Everywhere."
http://tidalwave.it/fabrizio/blog - fabrizio...@tidalwave.it

Ricky Clarkson

unread,
Sep 29, 2012, 3:30:50 PM9/29/12
to java...@googlegroups.com, Kevin Wright

I'd guess the ideas in the book work for Java and for Scala.  I'm sure the akka community will help you port anything you struggle with.

Fabrizio Giudici

unread,
Sep 29, 2012, 3:56:04 PM9/29/12
to java...@googlegroups.com, Ricky Clarkson, Kevin Wright
On Sat, 29 Sep 2012 21:30:50 +0200, Ricky Clarkson
<ricky.c...@gmail.com> wrote:

> I'd guess the ideas in the book work for Java and for Scala.

Sure, they're just best practices. But I find Scala absolutely unreadable
:o)


> I'm sure the akka community will help you port anything you struggle
> with.

... and I'd like not to bother people with the unavoidable beginner stuff
I'll deal with for some time.

Kevin Wright

unread,
Sep 29, 2012, 5:21:29 PM9/29/12
to Fabrizio Giudici, java...@googlegroups.com
Talking about "exchange of messages", I'm assuming you mean actors and not agents (which are a distinct concept).  The usual approach is to use a `TestActorRef` which then forces everything to be synchronous/deterministic and gives you access to the guts of the underlying actor implementation.

Surprisingly, this is one area where Akka doesn't provide an equivalent page for Java.  The ideas should be directly translatable to Java though.


As for community, Akka's is perhaps the most friendly of any in the Scala ecosystem.  Please don't hold back from asking even very-beginner-level questions there.  It might also be a good place to ask about Java-oriented documentation for the Akka test kit :)

Failing that... You can always ask on stack overflow, I've found it generally has a very fast turnover rate for questions on Akka or Scala, and you'll leave the answer in a place where it can more easily be found by the next person to ask!


--
Kevin Wright
mail: kevin....@scalatechnology.com
gtalk / msn : kev.lee...@gmail.com
vibe / skype: kev.lee.wright
steam: kev_lee_wright

"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra

Fabrizio Giudici

unread,
Sep 30, 2012, 3:10:08 AM9/30/12
to Kevin Wright, java...@googlegroups.com
On Sat, 29 Sep 2012 23:21:29 +0200, Kevin Wright
<kev.lee...@gmail.com> wrote:

> Talking about "exchange of messages", I'm assuming you mean actors and
> not
> agents (which are a distinct concept).

Yes, sorry, I meant actors. Please forgive me in this period if I write
this in place of that, but I'm suffering insomnia since a few weeks and
I'm not at 100%. :-(

The usual approach is to use a
> `TestActorRef` which then forces everything to be
> synchronous/deterministic
> and gives you access to the guts of the underlying actor implementation.
>
> Doc for scala is here:
> http://doc.akka.io/docs/akka/2.0.3/scala/testing.html
> Surprisingly, this is one area where Akka doesn't provide an equivalent
> page for Java. The ideas should be directly translatable to Java though.
>
>
> As for community, Akka's is perhaps the most friendly of any in the Scala
> ecosystem. Please don't hold back from asking even very-beginner-level
> questions there. It might also be a good place to ask about
> Java-oriented
> documentation for the Akka test kit :)

Ok, you convinced me. I'll just wait until I resume sleeping normally ;-)

Artie Peshimam

unread,
Oct 1, 2012, 6:41:23 AM10/1/12
to java...@googlegroups.com
Additionally I just saw that they are releasing a java test kit with 2.1

Link http://doc.akka.io/docs/akka/snapshot/java/testing.html

Reply all
Reply to author
Forward
0 new messages