In Corda Enterprise 4.2, I’m trying to wrap up an Unit Test using some custom made JPA tables, and I’m having problem with the following code:
serviceHub = MockServices(CordaX500Name.parse("O=OOO,L=Lambari,C=BR"))
serviceHub.withEntityManager{
val entityManager = this
test = CustomJPABackedClass()
entityManager.persist(test)
}
This code produces the following exception:
java.lang.UnsupportedOperationException
at net.corda.testing.node.MockServices.withEntityManager(MockServices.kt:412)
at project.support.CustomSupportTest$Companion.setupTest(CustomSupportTest.kt:70)
at project.support.CustomSupportTest.setupTest(CustomSupportTest.kt)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.hibernate.testing.junit4.BeforeClassCallbackHandler.evaluate(BeforeClassCallbackHandler.java:26)
at org.hibernate.testing.junit4.AfterClassCallbackHandler.evaluate(AfterClassCallbackHandler.java:25)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
How to properly use this MockServices
(or something else) to produce quick Unit tests ?
Aucun commentaire:
Enregistrer un commentaire