java - Test WebSocket in PlayFramework -


i have websocket in play application , want write test it, couldn't find example on how write such test. found discussion in play-framework google group there has been no activity recently.

so, there ideas on how test websocket's in java test?

you can retrieve underlying iteratee,enumerator , test them directly. way don't need use browser. need akka-testkit though, cope asynchronous nature of iteratees.

a scala example:

object websocket extends controller {   def websocket = websocket.async[jsvalue] { request =>     future.successful(iteratee.ignore[jsvalue] -> enumerator.apply[jsvalue](json.obj("type" -> "error")))      } }  class websocketspec extends playspecification {       "websocket" should {     "respond error packet" in new withapplication {       val request = fakerequest()        var message: jsvalue = null       val iteratee = iteratee.foreach[jsvalue](chunk => message = chunk)(akka.system.dispatcher)        controller.websocket().f(request)(enumerator.empty[jsvalue],iteratee)        testkit.awaitcond(message == json.obj("type" -> "error"), 1 second)     }   } } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -