I have two questions:
1) How to set the servlet context for a JerseyTesttest that extends JerseyTest. From my research, it seems that I need to create TestContainerfor TestFactoryand pass on AppDescriptor, but it seems more complex than it should be. Are there any other suggestions there?
In general, I was looking for a way to set the servlet context in the unit test of my Jersey resource class, which is usually run by web.xml.
Example:
@Path(value = "/service")
public class Foo{
@Context ServletContext ctx;
@GET
@Path(value="/list")
public String list() {
Controller ctrl = new Controller();
ctx.setAttribute("controller", ctrl);
return ctrl.getList();
}
}
public class FooUnitTest extends JerseyTest
{
@Test
public void testService()
{
}
}
The goal is to have a controller layout so that I can pass it into context.
2) What is the difference between using a jersey test from
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly</artifactId>
<version>1.5-SNAPSHOT</version>
<scope>test</scope>
</dependency>
vs
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-bundle</artifactId>
<version>2.4.1</version>
</dependency>
This is a jersey frame 2.5