I'm getting desperate on a few tests classes. I think I kind of narrowed down the problem but I'm out of ideas for how to fix it.
TLDR: how to properly tear down a DropwizardAppRule instance in order to use a different one in another class?
Or maybe force a configured bundle to refresh from the rule ?
To test two different configurations of our application (a configured bundle is slightly changing according to configuration file), I instantiate two DropwizardAppRule
with different configuration files in my tests. The tests run fine if run alone, but there are errors if they don't run one after another in the "Correct" order.
The error looks like a side effect, I guess I was not able to cleanly restart DropwizardAppRule
with another config.
I started by making custom rule extending the first one, then separate rules implementing TestRule (both instanciating DropwizardAppRule), I tried using JUnit @After, tried adding after rules, tried closing stuff in the life-cycle ... until I ran out of ideas.
I finally went back to Rules extending each other: CockpitLdapApplicationRule extends CockpitApplicationRule and worked around by putting Ldap tests in a package starting by "z" and setting maven to run tests in alphabetical order ...
I created a branch if someone cares to take a look at it.
The error :
org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=text/html;charset=iso-8859-1, type=class org.ow2.petals.cockpit.server.resources.UserSession$CurrentUser, genericType=class org.ow2.petals.cockpit.server.resources.UserSession$CurrentUser.
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$TerminalReaderInterceptor.aroundReadFrom(ReaderInterceptorExecutor.java:231)
at org.glassfish.jersey.message.internal.ReaderInterceptorExecutor.proceed(ReaderInterceptorExecutor.java:155)
at org.glassfish.jersey.message.internal.MessageBodyFactory.readFrom(MessageBodyFactory.java:1085)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:874)
at org.glassfish.jersey.message.internal.InboundMessageContext.readEntity(InboundMessageContext.java:808)
at org.glassfish.jersey.client.ClientResponse.readEntity(ClientResponse.java:326)
at org.glassfish.jersey.client.InboundJaxrsResponse$1.call(InboundJaxrsResponse.java:115)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:419)
at org.glassfish.jersey.client.InboundJaxrsResponse.runInScopeIfPossible(InboundJaxrsResponse.java:267)
at org.glassfish.jersey.client.InboundJaxrsResponse.readEntity(InboundJaxrsResponse.java:112)
at org.ow2.petals.cockpit.server.security.UserSessionTest.testLogout(UserSessionTest.java:70)
I'm using Dropwizard 1.1.4.
To reproduce: a test suite that fails and another that succeeds, changing only the execution order.
Any input would be very appreciated at this point, I'm feeling like I'm looking in the wrong direction. I know it is a very vague question, I'll be happy to improve it with some inputs.
Thanks in advance!