Hello,
We've run into a problem when running a multitude of tests that extend a base class that extends the JerseyTest.
We're using the GrizzlyWebTestContainer and have all the resources injected via Spring. Each test run individually is fine but when run as a whole a lot of threads are spun and OutOfMemoryExceptions occur. Increasing the memory allocated allowed the tests to run through but unacceptably slow.
SelectorThreads are spun per object spawned by the Factory that are asked for @Before each resource test. That is, each test spins a thread and the "suite" falls on its face.
Unfortunately, the InMemoryTestContainer (desirable: skips the HTTP portion, focuses on the resources, a lot quicker) does not "see" provider classes (even though it sees the root resources via spring injected context.xml) out of the box so a quick TestContainerFactory swap won't work. I suspect differences between WebAppDescriptor and LowLevelDescriptor is at fault.
My question is what are the best practices for writing test suites of this sort using the JerseyTest framework and JUnit 4? Currently the only annotations that are employed are @Test, @Before and @After. Ideally we'd like each test to be part of a suite of tests that has a WebTestContainer created at the beginning of the entire suite of tests rather than each individual test and have the WebAppDescriptor replaced @Before each individual @Test.
I am hoping this approach will solve excessive threads that hang around after starting/stopping the GrizzlyWebTestContainer but I'm open to any and all suggestions.
Thank you,
Bartosz Bobnis
Software Developer
Primal