spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Akka - Test that function from test executed


How about this:

trait MyActor extends
Actor{self:MyTrait

   def recieve = {
       case SayHello => printHelloWorld
   }
}

class MyMainActor extends MyActor with MyTrait

"My Actor" should{
"println hello msg if SayHello sent" in{
     class MockActor extends MyActor with
SomeMyTrait

      val x = new MockActor
      val myActor = system.actorOf(Props(x))
      myActor ! SayHello

      Thread.sleep(500)
      there was atLeastOne(x).printHelloMessage
   }

In general for actors, I am not a fan of above like testing. Akka Test-kit is brilliant. I would highly recommend looking at it.

In which I would do :

trait MyTrait{

  def printHelloWorld(){
    println("hello world")

  }

}

case object SayHello
case object Printed

class MyActor extends Actor with MyTrait{

   def recieve = {
       case SayHello => printHelloWorld
                        sender ! Printed
   }
} 

import akka.actor.ActorSystem
import akka.testkit.{ TestProbe, ImplicitSender,
TestKit }
import org.scalatest.matchers.ShouldMatchers
import org.scalatest.{ BeforeAndAfterAll, FunSuite
}    
import scala.concurrent.duration._

class MyTest extends
TestKit(ActorSystem("MyTest1"))
  with FunSuite
  with BeforeAndAfterAll
  with ShouldMatchers
  with ImplicitSender{

  override def afterAll() { system.shutdown() }
  test("MyTrait is called when triggered") {
    val x = TestProbe()
    val myActor = system.actorOf(Props(new
MyActor))
    myActor.send(x, SayHello)
    x.expectMsg(Printed)

}

Categories : Scala

Related to : Akka - Test that function from test executed
delphi popup menu click event is not just executed when mouse click the menu item but executed after some function execution
If you would set some breakpoints and use F8 to step through your code you would see what is wrong. Anywhay the reason why the message displayed is 'Item1 Clicked!' is becouse that is set to FMsg variable at the time. The flow of your code is like this: //Popup Menu Item1 Click event handler procedure MyForm.Item1Click(Sender: TObject); begin FMsg := 'Item1 Clicked!'; //4. Called after yo

Categories : Delphi
Create event function gets executed in creation
Events bubble to parents also. You can prevent this by using event.stopPropagation() $('.trig').click(function (e) { e.stopPropagation(); $('.menu').show(); $('body').click( function () { alert('boo'); }); }); Since you are adding a click handler to the body before the event is over it is also being triggered on the body Reference: https://developer.mozilla.org/en

Categories : Javascript
Aspects not getting executed
I created simple project with all provided by you information and can't reproduce your problem in simple setup, so you have correct implementation of your beans/aspects. One possible and common error is defining aspect in one context and bean in another, for example aspect is defined in applicationContext and bean is defined in dispatcherServletContext. In such configuration aspect will not work

Categories : Java
Can someone tell me why this animation is only being executed once? (Javafx)
The animation keeps playing... but it's doing nothing. The first time x=false, performs some changes, but then x is always false, and there's nothing to change. For instance, if you want to create a back and forwards indefinite effect, do this: boolean x = false; @Override public void start(Stage primaryStage) { ... EventHandler<ActionEvent> eH = e -> { if (x == false)

Categories : Java
How to call a Servlet/Filter before a JSP is executed in CQ5?
But by this method I would have to go through a URL like "/bin/.*". You can also register a servlet against a resource type, as well as by path, e.g. (from the Sling documentation): @SlingServlet( resourceTypes = "sling/servlet/default", selectors = "hello", extensions = "html", methods = "GET") public class MyServlet extends SlingSafeMethodsServlet { @Override prote

Categories : Java
Recently Add
head :: tail pattern matching for strings
What is the easiest and most efficient way to make a min heap in Scala?
Removing mutable collections and making it look more scala style
Reverse list of n elements
scalac: Error: object CharRef in intelliJ 14
Scala - trouble with type inference in lambda expression
Exception on spark test
How can I emulate Haskell's typeclasses in Scala?
Slick: CRUD extension: How to encapsulate implicit mapping:BaseColumnType[T]
Can't find Traverse for sequencing Seq[ValidationNel[String, MyCaseClass]] => ValidationNel[String, Seq[MyCaseClass]]
Tail recursion: internal "loop" function or default values for accumulators
Scala - Add element:MyType to Array = option[MyType] expected
Scala, Composing Function with two values
Using dependent type to generate compile error
How to match all words in a sentence with scala combinators?
Parser Alternative Operator | Fails
ScalaTest assertion mismatch due to Physical Address
Scala implicit parameter and japanese smiley 'foldLeft'
Is it possible to user reduceByKey((x, y, z) => ...)?
How to implement security Authorization using scala and play?
SSO login using scala script
Sum elements based on a predicate
Keep track of completed Futures
API Observable with dynamic caching
java.io.IOException: Remotely closed in gatling
Scala permutations using two lists
Is Scala Either really a Monad
Spark: Use of distinct
Identifying two type wildcards as identical
how to package spark scala application
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.