在1秒的Scala喷雾测试中,请求既未完成也未被拒绝
发布时间:2020-12-16 19:15:23 所属栏目:安全 来源:网络整理
导读:我目前正在测试一个Web服务,并且我继续遇到Web服务测试失败的错误,因为它正在超时.我试图将超时延长到5秒.我正在尝试 mimic a solution在Scala Spray google群组论坛上发布的一些内容无济于事.这是我试图在我的测试中使用的代码: import akka.testkit._impo
我目前正在测试一个Web服务,并且我继续遇到Web服务测试失败的错误,因为它正在超时.我试图将超时延长到5秒.我正在尝试
mimic a solution在Scala Spray google群组论坛上发布的一些内容无济于事.这是我试图在我的测试中使用的代码:
import akka.testkit._ import akka.actor.ActorSystem import com.github.nfldb.config.{NflDbApiActorSystemConfig,NflDbApiDbConfigTest} import org.scalatest.MustMatchers import org.specs2.mutable.Specification import spray.testkit.Specs2RouteTest import spray.routing.HttpService import spray.http.StatusCodes._ import spray.json.DefaultJsonProtocol._ import spray.httpx.SprayJsonSupport._ import concurrent.duration._ /** * Created by chris on 8/25/15. */ class NflPlayerScoringSvcTest extends Specification with Specs2RouteTest with NflPlayerScoringService with NflDbApiDbConfigTest with NflDbApiActorSystemConfig { import PlayerScoreProtocol.playerScoreProtocol implicit def actorRefFactory = actorSystem implicit def default(system: ActorSystem = actorSystem) = RouteTestTimeout(new DurationInt(5).second.dilated) "NflPlayerScoringSvc" should { "return hello" in { Get("/hello") ~> nflPlayerScoringServiceRoutes ~> check { responseAs[String] must contain("Say hello") } } "calculate a player's score for a given week" in { import PlayerScoreProtocol.playerScoreProtocol Get("/playerScore?playerId=00-0031237&gsisId=2015081551") ~> nflPlayerScoringServiceRoutes ~> check { val playerScore : DfsNflScoringEngineComponent.PlayerScore = responseAs[DfsNflScoringEngineComponent.PlayerScore] playerScore.playerId must be ("00-0031237") } } } } 这是我收到的错误: > test-only *NflPlayerScoringSvcTest* [info] Compiling 1 Scala source to /home/chris/dev/suredbits-dfs/target/scala-2.11/test-classes... 15:54:54.639 TKD [com-suredbits-dfs-nfl-scoring-NflPlayerScoringSvcTest-akka.actor.default-dispatcher-4] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started 15:54:55.158 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-2] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started 15:54:55.228 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-2] INFO test test test - Trying to find score for player: 00-0031237 and optional gsisId: Some(2015081551) 15:54:55.228 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-2] INFO test test test - Searching for player 00-0031237 with optional game: Some(2015081551) 15:54:55.268 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-4] INFO c.s.d.n.s.NflPlayerScoringSvcTest - Creating database for class com.suredbits.dfs.nfl.scoring.NflPlayerScoringSvcTest [info] NflPlayerScoringSvcTest [info] [info] NflPlayerScoringSvc should [info] + return hello [info] x calculate a player's score for a given week [error] Request was neither completed nor rejected within 1 second (NflPlayerScoringSvcTest.scala:33) [info] [info] [info] Total for specification NflPlayerScoringSvcTest [info] Finished in 1 second,310 ms [info] 2 examples,1 failure,0 error [info] ScalaTest [info] Run completed in 3 seconds,455 milliseconds. [info] Total number of tests run: 0 [info] Suites: completed 0,aborted 0 [info] Tests: succeeded 0,failed 0,canceled 0,ignored 0,pending 0 [info] No tests were executed. [error] Failed: Total 2,Failed 1,Errors 0,Passed 1 [error] Failed tests: [error] com.suredbits.dfs.nfl.scoring.NflPlayerScoringSvcTest [error] (test:testOnly) sbt.TestsFailedException: Tests unsuccessful [error] Total time: 11 s,completed Aug 25,2015 3:54:56 PM > 15:54:56.799 TKD [NflDbApiActorSystemConfig-akka.actor.default-dispatcher-2] INFO c.s.d.n.s.NflPlayerScoringSvcTest - Calculating score for game: NflGame(2015081551,Some(56772),2015-08-16T00:00:00.000Z,NflPreSeasonWeek1,Saturday,2015,Preseason,true,HomeTeam(MIN,26,9,14,3,2),AwayTeam(TB,16,6,7,1),2015-05-22T21:54:43.143Z,2015-08-16T17:29:01.729Z) and player: NflPlayer(00-0031237,Some(T.Bridgewater),Some(Teddy Bridgewater),Some(Teddy),Some(Bridgewater),MIN,QB,Some(2543465),Some(http://www.nfl.com/player/teddybridgewater/2543465/profile),Some(5),Some(11/10/1992),Some(Louisville),Some(2),Some(74),Some(215),Active) 任何人都可以提供任何见解,我可以做些什么来延长Scala Spray的时间超时时间? 解决方法
这是解决方案
implicit def default(implicit system: ActorSystem) = RouteTestTimeout(new DurationInt(5).second.dilated(system)) 由于Scala中的隐式冲突,我必须将系统参数显式传递给扩展方法. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
热点阅读