将 Powerclass 用于使用 JAXB 的测试 class 时出现链接错误
Linkage error while using Powerclass for test class that uses JAXB
`java.lang.LinkageError: loader constraint violation: when resolving overridden method "com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshal
`Exception(Lorg/xml/sax/SAXException;)Ljavax/xml/bind/UnmarshalException;" the class loader (instance of org/powermock/core/classloader/MockClassLoader) of the current class, com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/SAXException used in the signature
我正在使用 Powermock 在 JUNIT 测试用例中模拟静态 class。由于我的 junit 使用 xml 文件,我得到的错误很少,我必须像下面那样使用 powermock ignore。
@PowerMockIgnore({ "javax.xml.*"})
@RunWith(PowerMockRunner.class)
我收到链接错误以及以下错误。请指教
javax.xml.transform.TransformerFactoryConfigurationError: Provider for class javax.xml.transform.TransformerFactory cannot be created
在我使用 powermockignore 中的所有三个导入后问题得到解决
@PowerMockIgnore({
"javax.xml.*",
"org.xml.*",
"org.w3c.*"
})
`java.lang.LinkageError: loader constraint violation: when resolving overridden method "com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshal
`Exception(Lorg/xml/sax/SAXException;)Ljavax/xml/bind/UnmarshalException;" the class loader (instance of org/powermock/core/classloader/MockClassLoader) of the current class, com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/SAXException used in the signature
我正在使用 Powermock 在 JUNIT 测试用例中模拟静态 class。由于我的 junit 使用 xml 文件,我得到的错误很少,我必须像下面那样使用 powermock ignore。
@PowerMockIgnore({ "javax.xml.*"})
@RunWith(PowerMockRunner.class)
我收到链接错误以及以下错误。请指教
javax.xml.transform.TransformerFactoryConfigurationError: Provider for class javax.xml.transform.TransformerFactory cannot be created
在我使用 powermockignore 中的所有三个导入后问题得到解决
@PowerMockIgnore({
"javax.xml.*",
"org.xml.*",
"org.w3c.*"
})