Search in sources :

Example 76 with ResourceConfig

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

the class InjectionManagerServerProviderTest method configure.

@Override
protected Application configure() {
    final ResourceConfig resourceConfig = new ResourceConfig(TestResource.class);
    resourceConfig.register(new AbstractBinder() {

        @Override
        protected void configure() {
            bind(new MyInjectedService("hello")).to(MyInjectedService.class);
        }
    });
    resourceConfig.register(new MyFeature());
    resourceConfig.register(new MyReaderInterceptor());
    resourceConfig.register(new MyWriterInterceptor());
    return resourceConfig;
}
Also used : AbstractBinder(org.glassfish.jersey.internal.inject.AbstractBinder) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 77 with ResourceConfig

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

the class ServerDestroyTest method testApplicationResource.

@Test
public void testApplicationResource() throws Exception {
    final Response response = target().request().get();
    assertThat(response.readEntity(String.class), is("writer-resource"));
    assertThat(response.getStringHeaders().getFirst("foo"), is("bar"));
    checkDestroyed(false);
    reloader.reload(new ResourceConfig(Resource.class));
    checkDestroyed(true);
}
Also used : Response(javax.ws.rs.core.Response) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Example 78 with ResourceConfig

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

the class ReloadTest method _createRC.

private ResourceConfig _createRC(Reloader r) {
    final ResourceConfig result = new ResourceConfig(One.class);
    result.registerInstances(r);
    return result;
}
Also used : ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 79 with ResourceConfig

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

the class UriConnegLanguageMediaTypeTest 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"));
    Map<String, String> languages = new HashMap<>();
    languages.put("english", "en");
    languages.put("french", "fr");
    ResourceConfig rc = new ResourceConfig(LanguageVariantResource.class);
    rc.property(ServerProperties.LANGUAGE_MAPPINGS, languages);
    rc.property(ServerProperties.MEDIA_TYPE_MAPPINGS, mediaTypes);
    return rc;
}
Also used : HashMap(java.util.HashMap) MediaType(javax.ws.rs.core.MediaType) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Example 80 with ResourceConfig

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

the class UriConnegLanguageTest method configure.

@Override
protected Application configure() {
    Map<String, String> languages = new HashMap<>();
    languages.put("english", "en");
    languages.put("french", "fr");
    ResourceConfig rc = new ResourceConfig(LanguageVariantResource.class);
    rc.property(ServerProperties.LANGUAGE_MAPPINGS, languages);
    return rc;
}
Also used : HashMap(java.util.HashMap) ResourceConfig(org.glassfish.jersey.server.ResourceConfig)

Aggregations

ResourceConfig (org.glassfish.jersey.server.ResourceConfig)357 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 Resource (org.glassfish.jersey.server.model.Resource)24 URI (java.net.URI)23 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