See: Description
Class | Description |
---|---|
AppDescriptor |
The base application descriptor.
|
AppDescriptor.AppDescriptorBuilder<T extends AppDescriptor.AppDescriptorBuilder,V extends AppDescriptor> |
The base builder for building an application descriptor.
|
JerseyTest |
An abstract JUnit 4.x-based unit test class for testing JAX-RS and
Jersey-based applications.
|
LowLevelAppDescriptor |
A low-level application descriptor.
|
LowLevelAppDescriptor.Builder |
The builder for building a low-level application descriptor.
|
WebAppDescriptor |
A Web-based application descriptor.
|
WebAppDescriptor.Builder |
The builder for building a Web-based application descriptor.
|
WebAppDescriptor.FilterDescriptor |
The JerseyTest
class may be extended
to define the testing configuration and functionality.
For example, the following class is configured to use the low-level Grizzly
test container factory,
com.sun.jersey.test.framework.spi.container.grizzly.GrizzlyTestContainerFactory
,
and test that a simple resource, TestResource
returns the
expected results for a GET request.
public class SimpleLowLevelGrizzlyTest extends JerseyTest { @Path("root") public static class TestResource { @GET public String get() { return "GET"; } } public SimpleLowLevelGrizzlyTest() { super(new LowLevelAppDescriptor.Builder(TestResource.class). contextPath("context"). build()); } @Override protected TestContainerFactory getTestContainerFactory() { return new GrizzlyTestContainerFactory(); } @Test public void testGet() { WebResource r = resource().path("root"); String s = r.get(String.class); Assert.assertEquals("GET", s); } }
The following tests the same functionality using the Web-based Grizzly
test container factory,
com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory
.
The above test is actually not specific to any Web-based test container factory and will work for all provided test container factories, however the default factory will be thepackage foo; public class WebBasedTest extends JerseyTest { @Path("root") public static class TestResource { @GET public String get() { return "GET"; } } public WebBasedTest() { super(new WebAppDescriptor.Builder("foo"). contextPath("context"). build()); } @Test public void testGet() { WebResource r = resource().path("root"); String s = r.get(String.class); Assert.assertEquals("GET", s); } }
com.sun.jersey.test.framework.spi.container.grizzly.web.GrizzlyWebTestContainerFactory
.
See the documentation on JerseyTest
for
more details on how to set the default test container factory.Copyright © 2013 Oracle Corporation. All rights reserved.