jersey 2.0 - Running JerseyTest with PowerMock Exception for LoggingFeature.Verbosity -


edit 1

pom.xml

<!-- test dependencies --> <dependency>     <groupid>javax.servlet</groupid>     <artifactid>servlet-api</artifactid>     <scope>test</scope> </dependency> <dependency>     <groupid>junit</groupid>     <artifactid>junit</artifactid>     <scope>test</scope> </dependency> <dependency>     <groupid>org.easymock</groupid>     <artifactid>easymock</artifactid>     <scope>test</scope> </dependency> <dependency>     <groupid>com.sun.jersey.jersey-test-framework</groupid>     <artifactid>jersey-test-framework-core</artifactid>     <version>1.18</version>     <scope>test</scope> </dependency> <dependency>     <groupid>org.glassfish.jersey.test-framework.providers</groupid>     <artifactid>jersey-test-framework-provider-grizzly2</artifactid>     <version>2.23</version>     <scope>test</scope> </dependency>  <dependency>     <groupid>org.mockito</groupid>     <artifactid>mockito-all</artifactid>     <version>1.10.19</version>     <scope>test</scope> </dependency>  <dependency>     <groupid>org.powermock</groupid>     <artifactid>powermock-core</artifactid>     <version>1.6.2</version>     <scope>test</scope> </dependency>  <dependency>     <groupid>org.powermock</groupid>     <artifactid>powermock-api-mockito</artifactid>     <version>1.6.2</version>     <scope>test</scope> </dependency>  <dependency>     <groupid>org.powermock</groupid>     <artifactid>powermock-module-junit4</artifactid>     <version>1.6.2</version>     <scope>test</scope> </dependency>  <dependency>     <groupid>commons-discovery</groupid>     <artifactid>commons-discovery</artifactid>     <version>0.5</version>     <scope>test</scope> </dependency>  <dependency>     <groupid>cglib</groupid>     <artifactid>cglib</artifactid>     <version>2.2.2</version>     <scope>test</scope> </dependency> 

if remove @powermockrunner , @preparefortest attributes, test run without exception.

configurationresourcetest.java

@runwith(powermockrunner.class) @preparefortest({ configurationresource.class }) public class configurationresourcetest extends jerseytest {      @override     protected application configure() {         return new resourceconfig(configurationresource.class);     }      @test     public void test() throws exception {         inputstream propertiesstream = this.getclass().getclassloader().getresourceasstream("config.properties");         properties properties = new properties();         properties.load(propertiesstream);          configuration configuration = mock(configuration.class);         when(configuration.getproperties()).thenreturn(properties);          powermockito.whennew(configuration.class).withnoarguments().thenreturn(configuration);          configurationresource resource = new configurationresource();          final string config = resource.getconfiguration(null);          assertequals("{}", config);     }  } 

original post

when trying use @powermockrunner , @preparefortest jerseytest , exception thrown.

java.lang.illegalstateexception: failed transform class name org.glassfish.jersey.test.jerseytest. reason: cannot find org.glassfish.jersey.logging.loggingfeature$verbosity      @ org.powermock.core.classloader.mockclassloader.loadmockclass(mockclassloader.java:266)     @ org.powermock.core.classloader.mockclassloader.loadmodifiedclass(mockclassloader.java:180)     @ org.powermock.core.classloader.defersupportingclassloader.loadclass(defersupportingclassloader.java:68)     @ java.lang.classloader.loadclass(classloader.java:358)     @ java.lang.classloader.defineclass1(native method)     @ java.lang.classloader.defineclass(classloader.java:800)     @ java.lang.classloader.defineclass(classloader.java:643)     @ org.powermock.core.classloader.mockclassloader.loadmockclass(mockclassloader.java:269)     @ org.powermock.core.classloader.mockclassloader.loadmodifiedclass(mockclassloader.java:180)     @ org.powermock.core.classloader.defersupportingclassloader.loadclass(defersupportingclassloader.java:68)     @ java.lang.classloader.loadclass(classloader.java:358)     @ java.lang.class.forname0(native method)     @ java.lang.class.forname(class.java:278)     @ org.powermock.modules.junit4.common.internal.impl.junit4testsuitechunkerimpl.createdelegatorfromclassloader(junit4testsuitechunkerimpl.java:145)     @ org.powermock.modules.junit4.common.internal.impl.junit4testsuitechunkerimpl.createdelegatorfromclassloader(junit4testsuitechunkerimpl.java:40)     @ org.powermock.tests.utils.impl.abstracttestsuitechunkerimpl.createtestdelegators(abstracttestsuitechunkerimpl.java:244)     @ org.powermock.modules.junit4.common.internal.impl.junit4testsuitechunkerimpl.<init>(junit4testsuitechunkerimpl.java:61)     @ org.powermock.modules.junit4.common.internal.impl.abstractcommonpowermockrunner.<init>(abstractcommonpowermockrunner.java:32)     @ org.powermock.modules.junit4.powermockrunner.<init>(powermockrunner.java:34)     @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method)     @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57)     @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45)     @ java.lang.reflect.constructor.newinstance(constructor.java:526)     @ org.junit.internal.builders.annotatedbuilder.buildrunner(annotatedbuilder.java:104)     @ org.junit.internal.builders.annotatedbuilder.runnerforclass(annotatedbuilder.java:86)     @ org.junit.runners.model.runnerbuilder.saferunnerforclass(runnerbuilder.java:59)     @ org.junit.internal.builders.alldefaultpossibilitiesbuilder.runnerforclass(alldefaultpossibilitiesbuilder.java:26)     @ org.junit.runners.model.runnerbuilder.saferunnerforclass(runnerbuilder.java:59)     @ org.junit.internal.requests.classrequest.getrunner(classrequest.java:33)     @ org.junit.internal.requests.filterrequest.getrunner(filterrequest.java:36)     @ com.intellij.junit4.junit4ideatestrunner.startrunnerwithargs(junit4ideatestrunner.java:42)     @ com.intellij.rt.execution.junit.junitstarter.preparestreamsandstart(junitstarter.java:234)     @ com.intellij.rt.execution.junit.junitstarter.main(junitstarter.java:74) caused by: javassist.cannotcompileexception: cannot find org.glassfish.jersey.logging.loggingfeature$verbosity     @ javassist.expr.newexpr.replace(newexpr.java:215)     @ org.powermock.core.transformers.impl.mainmocktransformer$powermockexpressioneditor.edit(mainmocktransformer.java:418)     @ javassist.expr.expreditor.loopbody(expreditor.java:212)     @ javassist.expr.expreditor.doit(expreditor.java:91)     @ javassist.ctclasstype.instrument(ctclasstype.java:1431)     @ org.powermock.core.transformers.impl.mainmocktransformer.transform(mainmocktransformer.java:74)     @ org.powermock.core.classloader.mockclassloader.loadmockclass(mockclassloader.java:251)     ... 32 more caused by: javassist.notfoundexception: org.glassfish.jersey.logging.loggingfeature$verbosity     @ javassist.classpool.get(classpool.java:450)     @ javassist.bytecode.descriptor.toctclass(descriptor.java:592)     @ javassist.bytecode.descriptor.getparametertypes(descriptor.java:439)     @ javassist.expr.newexpr.replace(newexpr.java:188)     ... 38 more 


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -