我正在使用powermockpowermock-easymock-1.5-full.jar。出现以下异常。
这些是我的类路径中的所有jar文件,并作为powermock包从http://code.google.com/p/powermock/downloads/detail?name=powermock-easymock-testng-1.5.zip&can=2&q=下载
- easymock-3.1.jar
- javassist-3.17.1-GA.jar
- jcommander-1.27.jar
- objenesis-1.2.jar
- snakeyaml-1.6.jar
- testng-6.8.jar
- bsh-2.0b4.jar
- cglib-nodep-2.2.2.jar
- powermock-easymock-1.5-full.jar
java.lang.ClassCastException: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory
at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
at com.eibus.localization.message.MessageSet._tryGetMessageText(MessageSet.java:268)
at com.eibus.localization.message.Message._tryGetMessage(Message.java:135)
at com.eibus.localization.message.Message.getMessage(Message.java:110)
at com.eibus.localization.message.Message.getMessageWithLocaleFallBack(Message.java:155)
at com.eibus.localization.StringFormatter.getMessageWithFallBack(StringFormatter.java:141)
at com.eibus.localization.StringFormatter.format(StringFormatter.java:43)
at com.eibus.localization.LocalizableComposite.getMessage(LocalizableComposite.java:42)
at com.eibus.localization.exception.LocalizableException.getMessage(LocalizableException.java:168)
at com.eibus.localization.exception.LocalizableException.getLocalizedMessage(LocalizableException.java:130)
at java.lang.Throwable.toString(Throwable.java:479)
at java.lang.String.valueOf(Unknown Source)
at java.io.PrintWriter.println(Unknown Source)
at java.lang.Throwable$WrappedPrintWriter.println(Unknown Source)
at java.lang.Throwable.printStackTrace(Throwable.java:654)
at java.lang.Throwable.printStackTrace(Throwable.java:720)
at org.junit.runner.notification.Failure.getTrace(Failure.java:67)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener.testFailure(JUnit4TestListener.java:68)
at org.junit.runner.notification.RunNotifier$4.notifyListener(RunNotifier.java:100)
at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:41)
at org.junit.runner.notification.RunNotifier.fireTestFailure(RunNotifier.java:97)
at org.junit.internal.runners.MethodRoadie.addFailure(MethodRoadie.java:154)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.handleException(PowerMockJUnit44RunnerDelegateImpl.java:359)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl$PowerMockJUnit49MethodRunner.executeTest(PowerMockJUnit49RunnerDelegateImpl.java:93)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:284)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:209)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:148)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:122)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:101)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
请帮帮我
6条答案
按热度按时间cxfofazt1#
以下是对我有效的方法:
ibps3vxo2#
如果这是一个与PowerMock相关的问题,那么你可以尝试用以下内容注解你的测试类:
n3ipq98p3#
你可以忽略log4j.。我有同样的问题与jptool日志。我已经解决了忽略它这里是我的代码@PowerMockIgnore({“jptools."})
p1iqtdky4#
这是一个PowerMock问题,我遇到了这个错误:
你可以用这个注解来解决这个问题,试着用以下内容来注解你的测试类:
4xy9mtcn5#
您可以在
test/resources/org/powermock/extensions/
中创建一个configuration.properties
文件,其内容为:注意:属性值中必须使用逗号分隔,并且不能有空格,否则将无法工作!软件包列表取决于您的项目的依赖项。
PowerMock配置here。
jecbmhm36#
我在PowerMock v1.5.1和Log4j 2.19.0中遇到了类似的问题
为了解决这个问题,我将
org.apache.logging.logj4.*
添加到现有的@PowerMockIgnore
注解中,如下所示: