use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class AcceptQsTest method testProducesTwoMethodsBarFooResourceProgrammatic.
@Test
public void testProducesTwoMethodsBarFooResourceProgrammatic() throws Exception {
final Resource.Builder rb = Resource.builder("/");
rb.addMethod("GET").produces(MediaType.valueOf("application/bar")).handledBy(stringResponse("BAR"));
rb.addMethod("GET").produces(MediaType.valueOf("application/foo;qs=0.1")).handledBy(stringResponse("FOO"));
ResourceConfig rc = new ResourceConfig();
rc.registerResources(rb.build());
runTestFooBar(new ApplicationHandler(rc), "FOO", "BAR");
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class AcceptQsTest method testProducesOneMethodFooBarResourceProgrammatic.
@Test
public void testProducesOneMethodFooBarResourceProgrammatic() throws Exception {
final Resource.Builder rb = Resource.builder("/");
rb.addMethod("GET").produces(MediaType.valueOf("application/foo;qs=0.1"), MediaType.valueOf("application/bar")).handledBy(stringResponse("FOOBAR"));
ResourceConfig rc = new ResourceConfig();
rc.registerResources(rb.build());
runTestFooBar(new ApplicationHandler(rc), "FOOBAR", "FOOBAR");
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class AmbiguousTemplateTest method testPathParamOnAmbiguousTemplateTroughSubResourceLocator3.
@Test
public void testPathParamOnAmbiguousTemplateTroughSubResourceLocator3() throws ExecutionException, InterruptedException {
final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(SimpleLocator.class));
final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/locator/xyz/subxfoo", "GET").build()).get();
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("subx-xyz:null:subxfoo", response.getEntity());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class AmbiguousTemplateTest method testPathParamOnAmbiguousTemplate.
@Test
public void testPathParamOnAmbiguousTemplate() throws ExecutionException, InterruptedException {
final ApplicationHandler applicationHandler = new ApplicationHandler(new ResourceConfig(ResourceABC.class, ResourceXYZ.class));
final ContainerResponse response = applicationHandler.apply(RequestContextBuilder.from("/uuu/a", "GET").build()).get();
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals("a-abc:uuu", response.getEntity());
}
use of org.glassfish.jersey.server.ResourceConfig in project jersey by jersey.
the class AmbiguousTemplateTest method testOptionsOnChild.
@Test
public void testOptionsOnChild() throws ExecutionException, InterruptedException {
ResourceConfig resourceConfig = new ResourceConfig(ResourceA.class, ResourceB.class, ResourceQ.class);
ApplicationHandler app = new ApplicationHandler(resourceConfig);
final ContainerResponse containerResponse = app.apply(RequestContextBuilder.from("/resq/c", "OPTIONS").accept(MediaType.TEXT_PLAIN).build()).get();
Assert.assertEquals(200, containerResponse.getStatus());
final List<String> methods = Arrays.asList(containerResponse.getEntity().toString().split(", "));
assertThat(methods, hasItems("PUT", "GET", "OPTIONS", "HEAD"));
assertThat(methods.size(), is(4));
}
Aggregations