spray.testkit的使用
来源:互联网 发布:fastjson map转json 编辑:程序博客网 时间:2024/05/22 10:54
具体
http://spray.io/documentation/1.2.3/spray-testkit/
依赖
name:="demo9"transitiveClassifiers := Seq("sources", "javadoc")resolvers += "spray repo" at "http://repo.spray.io"libraryDependencies ++= Seq( "com.typesafe.akka" % "akka-actor_2.2.5" % "2.3.12" withSources() withJavadoc(), "com.typesafe.akka" % "akka-testkit_2.2.5" % "2.3.12" withSources() withJavadoc(), "org.scalatest" % "scalatest_2.10" % "2.2.2" withSources() withJavadoc(), "org.specs2" %% "specs2" % "1.12.3" withSources() withJavadoc(), "com.jsuereth" %% "scala-arm" % "1.3", "org.json4s" %% "json4s-native" % "3.2.10" withSources() withJavadoc(), "org.json4s" %% "json4s-jackson" % "3.2.10" withSources() withJavadoc(), "io.spray" % "spray-can" % "1.2.3" withSources() withJavadoc(), "io.spray" % "spray-http" % "1.2.3" withSources() withJavadoc(), "io.spray" % "spray-httpx" % "1.2.3" withSources() withJavadoc(), "io.spray" % "spray-util" % "1.2.3" withSources() withJavadoc(), "io.spray" % "spray-testkit" % "1.2.3" withSources() withJavadoc(), "io.spray" % "spray-routing" % "1.2.3" withSources() withJavadoc() )
主要是
spray-http (with ‘provided’ scope)
spray-httpx (with ‘provided’ scope)
spray-routing (with ‘provided’ scope)
spray-util
akka-actor 2.2.x (with ‘provided’ scope, i.e. you need to pull it in yourself)
akka-testkit 2.2.x (with ‘provided’ scope, i.e. you need to pull it in yourself)
scalatest (with ‘provided’ scope, for the ScalatestRouteTest)
specs2 (with ‘provided’ scope, for the Specs2RouteTest)
编写的格式
REQUEST ~> ROUTE ~> check { ASSERTIONS}
大写的必须的
例如
Put("/34") ~> sealRoute(smallRoute) ~> check {}
必须提供一个
val actorRefFactory: ActorRefFactory = system
作为 service actor or the service test
一个基本的例子
import akka.actor.ActorRefFactoryimport org.specs2.mutable.Specificationimport spray.testkit.Specs2RouteTestimport spray.routing.HttpServiceimport spray.http.StatusCodes._class AppTest extends Specification with Specs2RouteTest with HttpService{ val actorRefFactory: ActorRefFactory = system val smallRoute = get{ pathSingleSlash{ complete{ <html> <body> <h1>Say hello to <i>spray</i>!</h1> </body> </html> } } ~ path("ping"){ complete("PONG") } } "The service" should { "return a greeting for GET requests to the root path" in { Put("/34") ~> sealRoute(smallRoute) ~> check { //handled must beFalse //responseAs[String] must contain("Say hello") status === MethodNotAllowed responseAs[String] === "HTTP method not allowed, supported methods: GET" } } }}
0 0
- spray.testkit的使用
- Akka TestKit测试包的使用
- Akka TestKit测试包的使用
- spray-can的初识
- 传统的Heap Spray(转)
- spray-scan , spray-client 与 spray-routing 简单的订阅系统
- spray-routing使用Case Class Extraction
- 使用Scala和Spray实现REST
- Heap Spray:高危漏洞的垫脚石
- apply方法和spray的dsl理解
- 基于Scala的REST框架Spray
- 演示Heap Spray(堆喷射)的原理
- 对Spray-can 启动http server的理解
- JIT spray
- Spray体系结构
- Spray Introduction
- Heap Spray
- spray-routing与spray-can例子
- fstat、stat和lstat 区别(转) http://www.cnitblog.com/guopingleee/archive/2008/11/13/51411.aspx
- (4.1.35.4)android中的native crash
- Java文件下载
- ios-断点续传
- JAVA- FileInputStream与FileReader的区别
- spray.testkit的使用
- Spring Mvc常用注解
- 【POJ2516】【最小费用流】
- uva 1395 - Slim Span(生成树)
- 简单的动画播放
- 1.Linux链接概念 http://www.cnblogs.com/itech/archive/2009/04/10/1433052.html
- 我的openwrt学习笔记(二十九)webserver之 thttpd
- 盘点大数据生态圈,那些繁花似锦的开源项目
- LNMP环境的基础搭建,即Linux、Nginx、MySQL、PHP环境