users@jersey.java.net

[Jersey] Re: Clearing Resource State Between _at_Tests

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Tue, 10 Jul 2012 08:59:01 +0200

Timothy,

you are not subscribed to this mailing list - you won't receive messages
unless you do that. (I've included you in a cc manually this time; see
http://java.net/projects/jersey/lists ).

thanks for filing that issue, sample test case would be nice (and if
you're into playing with Jersey sources, you can even fix that and send
a patch back to us (: ).

Regards,
Pavel

On 7/9/12 6:53 PM, Timothy M. Rodriguez wrote:
> Hi Pavel,
>
> I'm not sure why I didn't receive your reply iny inbox but I saw it on
> the archive.
>
> I took look at the source also looking for a hacky workaround but
> pretty much all the variables are final down to the web application
> impl, so there's no good place to provide a fresh set of resources.
>
> It definitely seems best solvable by moving the test container
> creation to the setUp method, like you mentioned.
>
> I've opened up a Jira improvement request and will post a sample test
> case within the next day. (Jersey-1279)
>
> Thanks!
>
> Tim
>
> On Tuesday, June 26, 2012, Timothy Rodriguez
> <timothy.rodriguez_at_gmail.com <mailto:timothy.rodriguez_at_gmail.com>> wrote:
> > 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
> >