【问题标题】:IllegalArgumentException while running contract unit test in Kotlin (Corda)在 Kotlin (Corda) 中运行合同单元测试时出现 IllegalArgumentException
【发布时间】:2019-06-05 16:51:13
【问题描述】:

当我尝试运行我的 Junit 测试(用 Kotlin 编写)时,出现以下异常:

java.lang.IllegalArgumentException: Attempted to find dependent attachment for class javax/xml/bind/DatatypeConverter, but could not find a suitable candidate.

我尝试在以下代码中注释/取消注释某些行,似乎在我调用 command() 时发生异常

IRIssueTests 类 {

class DummyCommand : TypeOnlyCommandData()

private val ledgerServices = MockServices(listOf("com.my.package.name"))

private val ALICE = TestIdentity(CordaX500Name(organisation = "Alice", locality = "TestLand", country = "US"))

@Test
fun mustIncludeIssueCommand() {
    val ir = IRState(
        UniqueIdentifier(),
        mutableListOf(ALICE.party)
    )

    ledgerServices.ledger {
        transaction {
            output(IRContract.ID, ir)
            command(listOf(ALICE.publicKey), DummyCommand())
            fails()
        }
        transaction {
            output(IRContract.ID, ir)
            command(listOf(ALICE.publicKey), IRContract.Commands.Issue())
            verifies()
        }
    }
}

}

我想了解我收到此异常的原因以及如何解决它以使我的测试通过

【问题讨论】:

    标签: unit-testing kotlin corda


    【解决方案1】:

    Kotlin 测试必须使用 JDK8 运行。 在运行测试之前更改项目中 JDK8 的配置。 这样可以避免这个异常

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-26
      • 1970-01-01
      • 2021-12-05
      • 1970-01-01
      • 2013-02-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多