2016-08-15 178 views
1

我正在嘗試與akka和kotlin玩耍。我正在使用akka java API。 Actor類正常工作。但是我無法使用Akka-testkit實現測試用例。用Kotlin和akka-testkit測試akka演員

這是我的測試用例,

fun testWordCount() { 
    object : JavaTestKit(system) { 
     init { 
      val masterActor = system.actorOf(Props.create(WordCountActor.WordCountMaster::class.java), "master") 
      masterActor.tell(WordCountActor.StartCounting("src/main/resources/", 5), testActor) 
      val wcs = expectMsgClass(JavaTestKit.duration("5 seconds"), WordCountActor.WordCountSuccess::class.java) 
      object : JavaTestKit.Within(JavaTestKit.duration("5 seconds")) { 
       override fun run() { 
        Assert.assertEquals(20, wcs.result.size) 
       } 
      } 
     } 
    } 
} 

我得到下面的錯誤 -

Error:(39, 17) Kotlin: [Internal Error] org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Error generating constructors of class null with kind IMPLEMENTATION 
Cause: Error generating constructors of class null with kind IMPLEMENTATION 
File being compiled and position: (39,17) in /Users/kunalkanojia/Workspace/fun/kotlin_word_count/src/test/kotlin/WordCountActorTest.kt 
PsiElement: object : JavaTestKit.Within(JavaTestKit.duration("20 seconds")) { 
       override fun run() { 
        Assert.assertEquals(20, wcs.result.size.toLong()) 
       } 
      } 

我是新來的科特林,可能是什麼問題呢?

+0

代碼應該在Scala/Java中看起來如何? – voddan

+0

您正在使用哪個版本的Kotlin?下面的代碼([pastebin](http://pastebin.com/kxSD8ZBY))用Kotlin編譯器1.1.0-dev-2222 – soon

+0

正在使用1.0.3版編譯。代碼編譯得很好,但運行時會拋出錯誤。它看起來像這樣在Java - https://gist.github.com/kunalkanojia/8202d0690208949054eee8b88cec8da2 –

回答