Spring + PowerMock的测试失败了

时间:2014-06-30 22:03:58

标签: java spring powermock

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration({ "classpath:/WEB-INF/servlet.xml", "classpath:/WEB-INF/security.xml" })
@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
@PrepareForTest({ AccessLoginWebDatabase.class, AccessLoginWebDatabase.class })
public class AuthenticationControllerTestCase extends BaseTestCase {
   @Rule
   public PowerMockRule powerMockRule = new PowerMockRule();

   // Tests here...
}

当我运行此测试时,在运行测试之前会抛出错误:

com.thoughtworks.xstream.converters.ConversionException: javassist.NotFoundException: com.sun.proxy.$Proxy4 : javassist.NotFoundException: com.sun.proxy.$Proxy4
---- Debugging information ----
message             : javassist.NotFoundException: com.sun.proxy.$Proxy4
cause-exception     : java.lang.RuntimeException
cause-message       : javassist.NotFoundException: com.sun.proxy.$Proxy4
class               : java.lang.Class
required-type       : java.lang.Class
converter-type      : com.thoughtworks.xstream.converters.SingleValueConverterWrapper
wrapped-converter   : com.thoughtworks.xstream.converters.extended.JavaClassConverter
path                : /org.powermock.modules.junit4.rule.PowerMockStatement$1/outer-class/fNext/next/next/fNext/fTarget/wac/classLoader/classes/java-class[50]
line number         : 1637
class[1]            : java.util.Vector
converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[2]            : sun.misc.Launcher$AppClassLoader
converter-type[2]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[3]            : org.springframework.web.context.support.GenericWebApplicationContext
class[4]            : br.com.ericssoninovacao.shub.sync.AuthenticationControllerTestCase
class[5]            : org.junit.internal.runners.statements.InvokeMethod
class[6]            : org.junit.internal.runners.statements.RunBefores
class[7]            : org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks
class[8]            : org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks
class[9]            : org.powermock.modules.junit4.rule.PowerMockStatement
class[10]           : org.powermock.modules.junit4.rule.PowerMockStatement$1
version             : null
-------------------------------

其他人是否经历过此错误?
如何避免这个错误?

0 个答案:

没有答案