1
我有以下測試:沒有匹配的構造函數類的發現參數[]
it should "ask yarn about the running jobs" in new TestScope {
val testSender: TestProbe = TestProbe()
val testReceiver: TestProbe = TestProbe()
val yarnActorRef = system.actorOf(YarnActor.props(testReceiver.ref))
testSender.send(yarnActorRef, UpdateListOfJobs(Instant.now()))
testReceiver.expectMsg(YarnJobStatus("Not running"))
}
對於這個演員:
object YarnActor {
trait Message
case class UpdateListOfJobs(timeStamp: Instant) extends Message
def props(stateActorRef: ActorRef) = Props(new YarnActor(stateActorRef))
}
class YarnActor(stateActorRef: ActorRef) extends Actor with ActorLogging {
override def receive: Receive = {
case UpdateListOfJobs(timeStamp) => {
//check if the job is still running
val address = url("someUrlAddress")
val status: Future[String] = Await.ready(Http(address OK as.String), 1 second)
status onComplete {
case Success(message) => stateActorRef ! YarnJobStatus(message)
case Failure(_) => stateActorRef ! YarnJobStatus("Not running")
}
}
}
}
我越來越:
[info] - should ask yarn about the running jobs *** FAILED ***
[info] java.lang.IllegalArgumentException: no matching constructor found on class myPackage.YarnActor for arguments []
爲什麼這個錯誤出現了嗎? 在伴侶對象中,我使用1個參數構建我的actor(這應該是它所需要的)。
? –
'dispatch' http://dispatch.databinder.net/Dispatch.html – octavian