use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class UriTest method testManagedClientInjection3.
@Test
public void testManagedClientInjection3() throws ExecutionException, InterruptedException {
final ResourceConfig resourceConfig = new ResourceConfig(Resource4.class);
resourceConfig.property(Managed.class.getName() + ".property.test-property", "test-value");
resourceConfig.property(Managed.class.getName() + ".baseUri", "http://oracle.com");
initiateWebApplication(resourceConfig);
final ContainerResponse response = apply(RequestContextBuilder.from("/test/3", "GET").build());
assertEquals("http://oracle.com/relative", response.getEntity());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class HttpMethodOverrideFilterTest method testEnableFor.
@Test
public void testEnableFor() {
ResourceConfig rc = new ResourceConfig();
HttpMethodOverrideFilter.enableFor(rc, HttpMethodOverrideFilter.Source.HEADER);
assertTrue(rc.getClasses().contains(HttpMethodOverrideFilter.class));
assertEquals(1, ((HttpMethodOverrideFilter.Source[]) rc.getProperty(ServerProperties.HTTP_METHOD_OVERRIDE)).length);
assertEquals(HttpMethodOverrideFilter.Source.HEADER, ((HttpMethodOverrideFilter.Source[]) rc.getProperty(ServerProperties.HTTP_METHOD_OVERRIDE))[0]);
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class HttpMethodOverrideFilterTest method test.
public String test(HttpMethodOverrideFilter.Source... sources) {
ResourceConfig rc = new ResourceConfig(Resource.class);
HttpMethodOverrideFilter.enableFor(rc, sources);
ApplicationHandler handler = new ApplicationHandler(rc);
try {
ContainerResponse response = handler.apply(RequestContextBuilder.from("", "/?_method=DELETE", "POST").header("X-HTTP-Method-Override", "PUT").build()).get();
if (Response.Status.OK.equals(response.getStatusInfo())) {
return (String) response.getEntity();
} else {
return "" + response.getStatus();
}
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class HttpMethodOverrideFilterTest method testDefaultConfig.
@Test
public void testDefaultConfig() {
HttpMethodOverrideFilter f = new HttpMethodOverrideFilter(new ResourceConfig());
assertTrue(HttpMethodOverrideFilter.Source.HEADER.isPresentIn(f.config) && HttpMethodOverrideFilter.Source.QUERY.isPresentIn(f.config));
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class LayeredFiltersTest method testResourceMethod.
@Test
@Ignore("JERSEY-2414 - not yet implemented")
public void testResourceMethod() throws ExecutionException, InterruptedException {
final ResourceConfig resourceConfig = new ResourceConfig(ResourceWithSubresourceLocator.class).register(FilterOne.class).register(FilterTwo.class);
final ApplicationHandler application = new ApplicationHandler(resourceConfig);
final ContainerResponse response = application.apply(RequestContextBuilder.from("/sub", "GET").build()).get();
assertEquals(200, response.getStatus());
assertEquals("onetwo", response.getEntity());
List<Object> xTest = response.getHeaders().get("X-TEST");
assertEquals(2, xTest.size());
assertEquals("two", xTest.get(0));
assertEquals("one", xTest.get(1));
}
Aggregations