Search in sources :

Example 31 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.

the class UriConnegMediaTypeTest method configure.

@Override
protected Application configure() {
    Map<String, MediaType> mediaTypes = new HashMap<>();
    mediaTypes.put("foo", MediaType.valueOf("application/foo"));
    mediaTypes.put("bar", MediaType.valueOf("application/bar"));
    mediaTypes.put("foot", MediaType.valueOf("application/foot"));
    Set<Class<?>> classes = new HashSet<>();
    for (Class<?> c : UriConnegMediaTypeTest.class.getClasses()) {
        if (c.getAnnotation(Path.class) != null) {
            classes.add(c);
        }
    }
    ResourceConfig rc = new ResourceConfig(classes);
    rc.property(ServerProperties.MEDIA_TYPE_MAPPINGS, mediaTypes);
    return rc;
}
Also used : Path(javax.ws.rs.Path) HashMap(java.util.HashMap) MediaType(javax.ws.rs.core.MediaType) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) HashSet(java.util.HashSet)

Example 32 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.

the class ImplicitProducesViewProcessorTest method configure.

@Override
protected Application configure() {
    enable(TestProperties.DUMP_ENTITY);
    enable(TestProperties.LOG_TRAFFIC);
    return new ResourceConfig(ImplicitTemplate.class, ImplicitWithGetTemplate.class, ImplicitWithSubResourceGetTemplate.class).register(MvcFeature.class).register(TestViewProcessor.class).property("jersey.config.server.tracing", "ALL");
}
Also used : TestViewProcessor(org.glassfish.jersey.tests.e2e.server.mvc.provider.TestViewProcessor) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 33 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.

the class CustomConfigValidationTest method configure.

@Override
protected Application configure() {
    enable(TestProperties.DUMP_ENTITY);
    enable(TestProperties.LOG_TRAFFIC);
    final ResourceConfig resourceConfig = new ResourceConfig(CustomConfigResource.class);
    // Turn off BV in MOXy otherwise the entities on server would be validated at incorrect times.
    resourceConfig.register(moxyXmlFeature());
    resourceConfig.register(ValidationConfigurationContextResolver.class);
    resourceConfig.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    return resourceConfig;
}
Also used : ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 34 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.

the class BasicValidationTest method configure.

@Override
protected Application configure() {
    enable(TestProperties.DUMP_ENTITY);
    enable(TestProperties.LOG_TRAFFIC);
    final ResourceConfig resourceConfig = new ResourceConfig(BasicResource.class);
    resourceConfig.register(ContactBeanProvider.class);
    resourceConfig.register(MoxyXmlFeature.class);
    resourceConfig.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    return resourceConfig;
}
Also used : ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 35 with ResourceConfig

use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.

the class JsonProcessingTest method testJsonObject.

@Test
public void testJsonObject() throws Exception {
    final ResourceConfig resourceConfig = new ResourceConfig(Resource.class);
    final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
    final JsonObject jsonObject = Json.createObjectBuilder().add("foo", "bar").build();
    final Client client = ClientBuilder.newClient();
    final JsonObject entity = client.target(baseUri).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(jsonObject), JsonObject.class);
    System.out.println("RESULT = " + entity);
    assertEquals(jsonObject, entity);
    server.shutdownNow();
}
Also used : HttpServer(org.glassfish.grizzly.http.server.HttpServer) JsonObject(javax.json.JsonObject) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Client(javax.ws.rs.client.Client) Test(org.junit.Test)

Aggregations

ResourceConfig (org.glassfish.jersey.server.ResourceConfig)358 Test (org.junit.Test)135 ApplicationHandler (org.glassfish.jersey.server.ApplicationHandler)105 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)62 LoggingFeature (org.glassfish.jersey.logging.LoggingFeature)33 ServletContainer (org.glassfish.jersey.servlet.ServletContainer)29 Response (javax.ws.rs.core.Response)28 HttpServer (org.glassfish.grizzly.http.server.HttpServer)28 URI (java.net.URI)24 Resource (org.glassfish.jersey.server.model.Resource)24 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)23 IOException (java.io.IOException)22 ContainerRequestContext (javax.ws.rs.container.ContainerRequestContext)22 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)18 Server (org.eclipse.jetty.server.Server)17 ApplicationInfoListener (org.glassfish.jersey.server.internal.monitoring.ApplicationInfoListener)17 MonitoringEventListener (org.glassfish.jersey.server.internal.monitoring.MonitoringEventListener)17 MBeanExposer (org.glassfish.jersey.server.internal.monitoring.jmx.MBeanExposer)17 MetricRegistry (com.codahale.metrics.MetricRegistry)15 ContainerRequest (org.glassfish.jersey.server.ContainerRequest)15