2015-05-13 214 views
1

我有以下的測試案例:阿卡演員Testkit

class MutableStateActorTest extends TestKit(ActorSystem("MutableStateActorTest")) with WordSpecLike with Matchers { 

    "A MutableStateActor" must { 

    val actRef = TestActorRef[MutableStateActor] 

    "mutate state in order" in { 
     1 to 5 foreach { 
     x => actRef ! Increment 
     } 
    } 
    } 
} 

它不能簡單說是,但我得到以下錯誤,當我試圖運行它:

An exception or error caused a run to abort: Found class akka.actor.ActorPath, but interface was expected 
java.lang.IncompatibleClassChangeError: Found class akka.actor.ActorPath, but interface was expected 
    at akka.testkit.TestActorRef.<init>(TestActorRef.scala:47) 
    at akka.testkit.TestActorRef$.apply(TestActorRef.scala:141) 
    at akka.testkit.TestActorRef$.apply(TestActorRef.scala:137) 
    at akka.testkit.TestActorRef$.apply(TestActorRef.scala:146) 
    at akka.testkit.TestActorRef$.apply(TestActorRef.scala:144) 
    at q31.sandbox.statetest.MutableStateActorTest$$anonfun$1.apply$mcV$sp(MutableStateActorTest.scala:16) 
    at q31.sandbox.statetest.MutableStateActorTest$$anonfun$1.apply(MutableStateActorTest.scala:14) 
    at q31.sandbox.statetest.MutableStateActorTest$$anonfun$1.apply(MutableStateActorTest.scala:14) 

我猜猜它與Actor參考有關?

+0

您運行的是什麼版本的阿卡和你可能有多個版本阿卡對你r classpath? – cmbaxter

回答

3

您可能已經對阿卡的快照版本。在最新版本的akka​​ 2.4中,有些事情已經改變了,關於ActorRef,或者更好的說是ActorPath。您正在使用的庫是針對較舊版本的akka​​編譯的,因此預計ActorPath將成爲接口,而不是它在較新版本中的類。

的衝突的改變似乎是這樣的一個: https://github.com/akka/akka/commit/e6aea0b7d1bab7668072e1d92945ebb1865bdd9a

在這種變化(amongs其他東西以下改變: -sealed trait ActorPath extends Comparable[ActorPath] with Serializable { +sealed abstract class ActorPath extends Comparable[ActorPath] with Serializable {

爲了解決這個問題,無論是從你的快照搬走可能使用在自己的項目,或重新編譯從拋出錯誤的項目代碼,對阿卡(快照)版本你使用你自己。