users@jersey.java.net

[Jersey] Clearing Resource State Between _at_Tests

From: Timothy Rodriguez <timothy.rodriguez_at_gmail.com>
Date: Tue, 26 Jun 2012 11:20:09 -0400

Hi all,

I'm currently using the JerseyTest framework to test some of my
Resources but I am having issues clearing the state of the resources
between tests. I want each of the tests to be fully separable, so I
want the application to have fresh instances of all its resources
between tests.

It looks like JerseyTest doesn't do that by default, so I opted for
manually invoking the tearDown and setUp methods in my @Before method
to manually reset the container. However, it looks like this does not
fully reset the container as the stop method on the WebApplicationImpl
does not set the isInitiated flag to false--causing the same instances
of the resources to be used on startup.

What is the best method for ensuring tests are fully separable? Is
there a way to force a reinitiaion in my tests oe is there another way
I should be going about this?

Thanks,

Tim