Re: [akka-user] TestProbe() and actorSelection

2015-05-22 Thread Konstantinos Kougios

nice



On 22/05/15 14:49, Patrik Nordwall wrote:
The forwarding actor is actually included in 
akka.testkit.TestActors.ForwardActor 
 in 
Akka 2.4-M1.

/Patrik

On Fri, May 22, 2015 at 3:16 PM, Konstantinos Kougios 
mailto:kostas.koug...@googlemail.com>> 
wrote:


Thanks Patrik, I actually thought of that too but was wondering if
there is any testkit support for it. Then ended up impl a
test-only actor that gathers all received messages and my test
suite can get them as a stream (blocking if the stream is empty in
order to wait for the threading bit to work). Since this is a
normal actor, I can create it as I wish and also I can assert on
the messages via normal testActor.messages should contain(). I am
in the process of writing that code and will replace some of my
testcases/TestProbe's with it.


On 22/05/15 14:09, Patrik Nordwall wrote:

I would start an actor on that path that forwards all messages to
the test probe.
/Patrik

On Thu, May 21, 2015 at 7:22 AM, Kostas kougios
mailto:kostas.koug...@googlemail.com>> wrote:

Hi, I am trying to test actor code that uses actorSelection:

valpath =RootActorPath(member.address,name ="/user/clusterKeeper")
context.actorSelection(path).resolveOne(5seconds).foreach {
 clusterKeeper =>
   clusterKeeper ! msg
}


member.address comes from akka clusters and has the address
of the remote actor.

Now I need to mock/probe the clusterKeeper actor but
TestProbe() doesn't have a way of defining the name of the
actor or it's path. In fact it goes down to TestKitBase where
it is hardcoded:

valtestActor: ActorRef = {
   valimpl = system.asInstanceOf[ExtendedActorSystem]
   valref = impl.systemActorOf(TestActor.props(queue)
 .withDispatcher(CallingThreadDispatcher.Id),
  *__**_"testActor"+ TestKit.testActorId.incrementAndGet)
  _*  awaitCond(refmatch{
 caser: RepointableRef⇒r.isStarted
 case_⇒true
   },1second,10millis)
   ref
}


Is there a way with the testkit to test this? Ofcourse I
could create an actor myself but then I would have to reimpl
all expectMsg or maybe have it forward the messages to testkit.

Similar post :

https://groups.google.com/forum/#!searchin/akka-user/testprobe$20actorSelection/akka-user/ETL4XQr1Sj4/N9lo_6gc8voJ


-- 
>> 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.




-- 


Patrik Nordwall
Typesafe  - Reactive apps on the JVM
Twitter: @patriknw

-- 
>> 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 a topic
in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/akka-user/DK0evQ1utCA/unsubscribe.
To unsubscribe from this group and all its topics, 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.


-- 
>> 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 f

Re: [akka-user] TestProbe() and actorSelection

2015-05-22 Thread Patrik Nordwall
The forwarding actor is actually included in
akka.testkit.TestActors.ForwardActor

in
Akka 2.4-M1.
/Patrik

On Fri, May 22, 2015 at 3:16 PM, Konstantinos Kougios <
kostas.koug...@googlemail.com> wrote:

>  Thanks Patrik, I actually thought of that too but was wondering if there
> is any testkit support for it. Then ended up impl a test-only actor that
> gathers all received messages and my test suite can get them as a stream
> (blocking if the stream is empty in order to wait for the threading bit to
> work). Since this is a normal actor, I can create it as I wish and also I
> can assert on the messages via normal testActor.messages should contain().
> I am in the process of writing that code and will replace some of my
> testcases/TestProbe's with it.
>
>
> On 22/05/15 14:09, Patrik Nordwall wrote:
>
> I would start an actor on that path that forwards all messages to the test
> probe.
> /Patrik
>
> On Thu, May 21, 2015 at 7:22 AM, Kostas kougios <
> kostas.koug...@googlemail.com> wrote:
>
>> Hi, I am trying to test actor code that uses actorSelection:
>>
>> val path = RootActorPath(member.address, name = 
>> "/user/clusterKeeper")context.actorSelection(path).resolveOne(5 
>> seconds).foreach {
>> clusterKeeper =>
>>   clusterKeeper ! msg
>> }
>>
>>
>>
>> member.address comes from akka clusters and has the address of the remote
>> actor.
>>
>> Now I need to mock/probe the clusterKeeper actor but TestProbe() doesn't
>> have a way of defining the name of the actor or it's path. In fact it goes
>> down to TestKitBase where it is hardcoded:
>>
>> val testActor: ActorRef = {
>>   val impl = system.asInstanceOf[ExtendedActorSystem]
>>   val ref = impl.systemActorOf(TestActor.props(queue)
>> .withDispatcher(CallingThreadDispatcher.Id),*"testActor" + 
>> TestKit.testActorId.incrementAndGet)
>>  * awaitCond(ref match {
>> case r: RepointableRef ⇒ r.isStarted
>> case _ ⇒ true  }, 1 second, 10 millis)
>>   ref
>> }
>>
>>
>> Is there a way with the testkit to test this? Ofcourse I could create an
>> actor myself but then I would have to reimpl all expectMsg or maybe have it
>> forward the messages to testkit.
>>
>> Similar post :
>>
>> https://groups.google.com/forum/#!searchin/akka-user/testprobe$20actorSelection/akka-user/ETL4XQr1Sj4/N9lo_6gc8voJ
>>  --
>> >> 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.
>>
>
>
>
>  --
>
> Patrik Nordwall
> Typesafe  -  Reactive apps on the JVM
> Twitter: @patriknw
> --
> >> 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 a topic in the
> Google Groups "Akka User List" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/akka-user/DK0evQ1utCA/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>
>
>  --
> >> 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.
>



-- 

Patrik Nordwall
Typesafe  -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>  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 su

Re: [akka-user] TestProbe() and actorSelection

2015-05-22 Thread Konstantinos Kougios
Thanks Patrik, I actually thought of that too but was wondering if there 
is any testkit support for it. Then ended up impl a test-only actor that 
gathers all received messages and my test suite can get them as a stream 
(blocking if the stream is empty in order to wait for the threading bit 
to work). Since this is a normal actor, I can create it as I wish and 
also I can assert on the messages via normal testActor.messages should 
contain(). I am in the process of writing that code and will replace 
some of my testcases/TestProbe's with it.


On 22/05/15 14:09, Patrik Nordwall wrote:
I would start an actor on that path that forwards all messages to the 
test probe.

/Patrik

On Thu, May 21, 2015 at 7:22 AM, Kostas kougios 
mailto:kostas.koug...@googlemail.com>> 
wrote:


Hi, I am trying to test actor code that uses actorSelection:

valpath =RootActorPath(member.address,name ="/user/clusterKeeper")
context.actorSelection(path).resolveOne(5seconds).foreach {
 clusterKeeper =>
   clusterKeeper ! msg
}


member.address comes from akka clusters and has the address of the
remote actor.

Now I need to mock/probe the clusterKeeper actor but TestProbe()
doesn't have a way of defining the name of the actor or it's path.
In fact it goes down to TestKitBase where it is hardcoded:

valtestActor: ActorRef = {
   valimpl = system.asInstanceOf[ExtendedActorSystem]
   valref = impl.systemActorOf(TestActor.props(queue)
 .withDispatcher(CallingThreadDispatcher.Id),
  *__**_"testActor"+ TestKit.testActorId.incrementAndGet)
  _*  awaitCond(refmatch{
 caser: RepointableRef⇒r.isStarted
 case_⇒true
   },1second,10millis)
   ref
}


Is there a way with the testkit to test this? Ofcourse I could
create an actor myself but then I would have to reimpl all
expectMsg or maybe have it forward the messages to testkit.

Similar post :

https://groups.google.com/forum/#!searchin/akka-user/testprobe$20actorSelection/akka-user/ETL4XQr1Sj4/N9lo_6gc8voJ


-- 
>> 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.




--

Patrik Nordwall
Typesafe  - Reactive apps on the JVM
Twitter: @patriknw

--
>> 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 a topic in the 
Google Groups "Akka User List" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/akka-user/DK0evQ1utCA/unsubscribe.
To unsubscribe from this group and all its topics, 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.


--

 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.


Re: [akka-user] TestProbe() and actorSelection

2015-05-22 Thread Patrik Nordwall
I would start an actor on that path that forwards all messages to the test
probe.
/Patrik

On Thu, May 21, 2015 at 7:22 AM, Kostas kougios <
kostas.koug...@googlemail.com> wrote:

> Hi, I am trying to test actor code that uses actorSelection:
>
> val path = RootActorPath(member.address, name = "/user/clusterKeeper")
> context.actorSelection(path).resolveOne(5 seconds).foreach {
> clusterKeeper =>
>   clusterKeeper ! msg
> }
>
>
> member.address comes from akka clusters and has the address of the remote
> actor.
>
> Now I need to mock/probe the clusterKeeper actor but TestProbe() doesn't
> have a way of defining the name of the actor or it's path. In fact it goes
> down to TestKitBase where it is hardcoded:
>
> val testActor: ActorRef = {
>   val impl = system.asInstanceOf[ExtendedActorSystem]
>   val ref = impl.systemActorOf(TestActor.props(queue)
> .withDispatcher(CallingThreadDispatcher.Id),
>
> *"testActor" + TestKit.testActorId.incrementAndGet) * awaitCond(ref match {
> case r: RepointableRef ⇒ r.isStarted
> case _ ⇒ true
>   }, 1 second, 10 millis)
>   ref
> }
>
>
> Is there a way with the testkit to test this? Ofcourse I could create an
> actor myself but then I would have to reimpl all expectMsg or maybe have it
> forward the messages to testkit.
>
> Similar post :
>
> https://groups.google.com/forum/#!searchin/akka-user/testprobe$20actorSelection/akka-user/ETL4XQr1Sj4/N9lo_6gc8voJ
>
> --
> >> 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.
>



-- 

Patrik Nordwall
Typesafe  -  Reactive apps on the JVM
Twitter: @patriknw

-- 
>>  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-user] TestProbe() and actorSelection

2015-05-20 Thread Kostas kougios
Hi, I am trying to test actor code that uses actorSelection:

val path = RootActorPath(member.address, name = "/user/clusterKeeper")
context.actorSelection(path).resolveOne(5 seconds).foreach {
clusterKeeper =>
  clusterKeeper ! msg
}


member.address comes from akka clusters and has the address of the remote 
actor.

Now I need to mock/probe the clusterKeeper actor but TestProbe() doesn't 
have a way of defining the name of the actor or it's path. In fact it goes 
down to TestKitBase where it is hardcoded:

val testActor: ActorRef = {
  val impl = system.asInstanceOf[ExtendedActorSystem]
  val ref = impl.systemActorOf(TestActor.props(queue)
.withDispatcher(CallingThreadDispatcher.Id),

*"testActor" + TestKit.testActorId.incrementAndGet) * awaitCond(ref match {
case r: RepointableRef ⇒ r.isStarted
case _ ⇒ true
  }, 1 second, 10 millis)
  ref
}


Is there a way with the testkit to test this? Ofcourse I could create an 
actor myself but then I would have to reimpl all expectMsg or maybe have it 
forward the messages to testkit. 

Similar post :
https://groups.google.com/forum/#!searchin/akka-user/testprobe$20actorSelection/akka-user/ETL4XQr1Sj4/N9lo_6gc8voJ

-- 
>>  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.