2016-08-15 155 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 –

回答