java - JMockIt security exception signer information does not match -


when running jmockit , trying mock instance in testng loaded signed jar error along lines of (in case of jetty server):

failed configuration: @beforeclass startserver java.lang.securityexception: class "javax.servlet.filterregistration"'s signer information not match signer information of other classes in same package     @ java.lang.classloader.checkcerts(classloader.java:943)     @ java.lang.classloader.predefineclass(classloader.java:657)     @ java.lang.classloader.defineclass(classloader.java:785)     @ java.security.secureclassloader.defineclass(secureclassloader.java:142)     @ java.net.urlclassloader.defineclass(urlclassloader.java:449)     @ java.net.urlclassloader.access$100(urlclassloader.java:71)     @ java.net.urlclassloader$1.run(urlclassloader.java:361)     @ java.net.urlclassloader$1.run(urlclassloader.java:355)     ... 

the dependency order in pom correct, , without mocks tests run fine. tips java securityexception: signer information not match not here.

is there workaround?


here sample test up, should produce error. in case start entire container integration test:

public class myservlettest {     private final server server = new server(port);     private mockup<openidauthenticationprovider> openidap;      @beforeclass     public void startserver() throws exception {         final servletcontexthandler context = new servletcontexthandler(servletcontexthandler.sessions);         context.setcontextpath("/");         context.addservlet(myservlet.class, "/my/*");         this.server.sethandler(context);         this.server.start();         this.openidap = new mockup<openidauthenticationprovider>() {             @mock             void $init(final userdao userdao) {}         };     }      @test     ... } 

the openidauthenticationprovider called within myservlet , instantiated during startup, although i'm not sure matters.

the corresponding part in pom.xml looks this:

<dependencies>     <dependency>         <groupid>org.eclipse.jetty</groupid>         <artifactid>jetty-servlet</artifactid>         <version>9.0.3.v20130506</version>         <scope>test</scope>     </dependency>     <dependency>         <groupid>org.eclipse.jetty</groupid>         <artifactid>jetty-server</artifactid>         <version>9.0.3.v20130506</version>         <scope>test</scope>     </dependency>     <dependency>         <groupid>javax.servlet</groupid>         <artifactid>servlet-api</artifactid>         <version>2.5</version>         <scope>provided</scope>     </dependency> </dependencies> 

one way use jmockit deactivate certificate check. since jmockit (and other mocking frameworks) work via instrumentation, class can modified. here example how mock part of classloader, causes troubles:

@beforesuite public void deactivatecertchecker() {     new mockup<classloader>() {         @mock         void checkcerts(final string name, final codesource cs) {}     }; } 

mind though, not fix running program has signing issues, effect available during test runs, when mocking has been instrumented.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -