com.thoughtworks.xstream.converters.ConversionException: Could not call

1.7k views Asked by At

I have a situation to test SpringCamelContext unittest with PowerMockito and I am receiving following error.Does anybody know how to resolve it. If I apply

@Rule
    public PowerMockRule rule = new PowerMockRule();

And the following dependencies.

<dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4-rule</artifactId>
            <version>1.7.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-classloading-xstream</artifactId>
            <version>1.7.1</version>
            <scope>test</scope>
        </dependency>

then only i am getting following error:

 com.thoughtworks.xstream.converters.ConversionException: Could not call java.security.CodeSource.readObject() : null
    ---- Debugging information ----
    message             : Could not call java.security.CodeSource.readObject()
    cause-exception     : java.lang.RuntimeException
    cause-message       : null
    class               : java.security.CodeSource
    required-type       : java.security.CodeSource
    converter-type      : com.thoughtworks.xstream.converters.reflection.SerializableConverter
    path                : /org.powermock.modules.junit4.rule.PowerMockStatement$1/outer-class/fNext/next/next/target/template/camelContext/applicationContextClassLoader/parent/defaultDomain/codesource/java.security.CodeSource
    line number         : 18917
    class[1]            : java.security.ProtectionDomain
    converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
    class[2]            : sun.misc.Launcher$ExtClassLoader
    class[3]            : sun.misc.Launcher$AppClassLoader
    class[4]            : org.apache.camel.spring.SpringCamelContext
    class[5]            : org.apache.camel.impl.DefaultProducerTemplate
    class[6]            : com.narayan.dummy.test.drools.DroolsUnitTest
    class[7]            : org.junit.internal.runners.statements.InvokeMethod
    class[8]            : org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks
    class[9]            : org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks
    class[10]           : org.powermock.modules.junit4.rule.PowerMockStatement
    class[11]           : org.powermock.modules.junit4.rule.PowerMockStatement$1
    version             : 1.4.7

Does anybody know how to resolve it????

1

There are 1 answers

0
Narayan Yerrabachu On BEST ANSWER

In order to resolve this Problem. I replaced it with following annotations instead of PowerMockRule.

@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class)

Also removed dependencies powermock-module-junit4-rule & powermock-classloading-xstream from Pom.xml and it works.