use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class JaxRsRiBundleTest method testSimpleResource.
@Test
public void testSimpleResource() throws Exception {
final ResourceConfig resourceConfig = new ResourceConfig(SimpleResource.class);
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);
final Client client = ClientBuilder.newClient();
final String response = client.target(baseUri).path("/simple").request().get(String.class);
System.out.println("RESULT = " + response);
assertEquals("OK", response);
server.shutdownNow();
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class ParamConverterInternalTest method testLazyConverter.
@Test
public void testLazyConverter() throws Exception {
final ApplicationHandler application = new ApplicationHandler(new ResourceConfig(MyLazyParamProvider.class, Resource.class));
final ContainerResponse response = application.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
assertEquals(400, response.getStatus());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class ActiveBindingBindingTest method testReq.
@Test
@Ignore("At the time of ignoring this test, ResourceConfig does not support HK2 Binder registering.")
public void testReq() throws Exception {
// bootstrap the test application
ResourceConfig myConfig = new ResourceConfig();
myConfig.register(ReqResource.class);
myConfig.register(SingletonResource.class);
final MyRequestDataDescriptor activeDescriptor = new MyRequestDataDescriptor();
myConfig.register(new AbstractBinder() {
@Override
protected void configure() {
addActiveDescriptor(activeDescriptor);
}
});
initiateWebApplication(myConfig);
activeDescriptor.injectionManager = app().getInjectionManager();
// end bootstrap
String response;
response = getResponseEntity("/req");
assertThat(response, containsString(REQUEST_TAG));
assertThat(response, not(containsString(PROXY_TAG)));
response = getResponseEntity("/req/param");
assertThat(response, containsString(REQUEST_TAG));
assertThat(response, not(containsString(PROXY_TAG)));
response = getResponseEntity("/singleton");
assertThat(response, containsString(SINGLETON_TAG));
assertThat(response, containsString(PROXY_TAG));
response = getResponseEntity("/req");
assertThat(response, containsString(REQUEST_TAG));
assertThat(response, not(containsString(PROXY_TAG)));
response = getResponseEntity("/singleton");
assertThat(response, containsString(SINGLETON_TAG));
assertThat(response, containsString(PROXY_TAG));
response = getResponseEntity("/singleton/param");
assertThat(response, containsString(SINGLETON_TAG));
assertThat(response, not(containsString(PROXY_TAG)));
response = getResponseEntity("/singleton/param");
assertThat(response, containsString(SINGLETON_TAG));
assertThat(response, not(containsString(PROXY_TAG)));
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class UriTest method testManagedClientInjection2.
@Test
public void testManagedClientInjection2() throws ExecutionException, InterruptedException {
final ResourceConfig resourceConfig = new ResourceConfig(Resource4.class);
resourceConfig.property(Managed.class.getName() + ".property.test-property", "test-value");
initiateWebApplication(resourceConfig);
final ContainerResponse response = apply(RequestContextBuilder.from("/test/2", "GET").build());
assertEquals("test-value", response.getEntity());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class UriTest method testManagedClientInjection1.
@Test
public void testManagedClientInjection1() throws ExecutionException, InterruptedException {
final ResourceConfig resourceConfig = new ResourceConfig(Resource4.class);
// TODO introduce new ResourceConfig.setClientProperty(Class<? extends Annotation>, String name, Object value) helper method
resourceConfig.property(Managed.class.getName() + ".property.test-property", "test-value");
initiateWebApplication(resourceConfig);
final ContainerResponse response = apply(RequestContextBuilder.from("/test/1", "GET").build());
assertEquals("test-value", response.getEntity());
}
Aggregations