Spock + Drools测试 [英] Spock + Drools Testing
问题描述
我有一个关于SPOCK + Drools测试的问题。这是事情,
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
这行代码在JUnit测试用例中非常好用。它不在SPOCK内。
我得到以下异常,
<$ c $在org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
org.codehaus.groovy上的$ / $ / $ / $ / $ / $ / .util.LazyReference.get(LazyReference.java:33)
导致:java.lang.ClassNotFoundException:com.sun.tools.xjc.Options
... 3 more
可能是什么问题?它与流口水有关吗?无法获得令人满意的问题。任何帮助都非常感谢:)
更新:
我正在运行在没有部署的情况下在webapp中测试(如果这有什么意义:))。我添加了jar到类路径(不是WEB-INF / libs),它现在工作正常。
尽管OP状态在他的更新中,通过向classpath添加适当的库来解决问题,他没有指定库。
我相信这个问题可以通过将以下内容添加到您的依赖
build('com.sun.xml.bind:jaxb-xjc:2.1')
build('com .sun.xml.bind:jaxb-impl:2.1')
I have a question regarding SPOCK + Drools testing. Here's the thing,
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
That line of code works absolutely fine,inside a JUnit test case. It doesn't inside SPOCK.
I get the following exception,
java.lang.NoClassDefFoundError: com/sun/tools/xjc/Options
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.xjc.Options
... 3 more
What could be the problem? Is it drools related? Unable to get ny head riund the problem. Any help is much appreciated :)
Update:
I am running the test inside a webapp w/o it being deployed(if that makes any sense :)). I added the jar to the classpath(not WEB-INF/libs) and it is working fine now.
Although OP states in his update that the problem got fixed by adding appropriate libs to classpath, he does not specify the libs.
I believe this issue gets fixed by adding the following to your dependencies
build('com.sun.xml.bind:jaxb-xjc:2.1')
build('com.sun.xml.bind:jaxb-impl:2.1')
这篇关于Spock + Drools测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!