Last active
August 29, 2015 14:18
-
-
Save dat-vikash/2beaf89e541f481f441c to your computer and use it in GitHub Desktop.
Play 2.2.x WSClientVisitorSpec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WSClientVisitorSpec extends TestKit(_system = Akka.system(FakeApplication())) with WordSpecLike with Matchers with ImplicitSender | |
{ | |
//instantiate test constants | |
val actorRef = TestActorRef(new WSClientVisitor("TEST") with MockWebSocketChannel, name= "test") | |
// get a test reference to our actor | |
val actor = actorRef.underlyingActor | |
"Web Socket Client For Visitor" should { | |
"register a new socket" in new WithApplication(app = FakeApplication(additionalConfiguration =Map("akka.event-handlers" -> List("akka.testkit.TestEventListener")), | |
withGlobal = Some(new GlobalSettings() { | |
override def onStart(app: api.Application) { | |
Logger.info("Akka system up") | |
} | |
}))) { | |
// clear our channel | |
actor.mockWebSocketChannelQueue = List.empty | |
// send the RegisterSocket message and verify the data on the chaneel | |
actor.receive(RegisterSocket) | |
actor.mockWebSocketChannelQueue(0) \ "type" should equal(JsString(“event”)) | |
actor.mockWebSocketChannelQueue(0) \ "data" should equal(JsString(“connection_on”) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment