use of javax.ws.rs.core.Response in project jersey by jersey.
the class ExceptionViewProcessorTest method testResolvingClassExplicitTemplate.
@Test
public void testResolvingClassExplicitTemplate() throws IOException {
final Invocation.Builder request = target("/").request("application/wrong-media-type");
Response cr = request.get(Response.class);
assertEquals(406, cr.getStatus());
Properties p = new Properties();
p.load(cr.readEntity(InputStream.class));
assertEquals("/org/glassfish/jersey/tests/e2e/server/mvc/ExceptionViewProcessorTest/WebAppExceptionMapper/406.testp", p.getProperty("path"));
assertEquals("406", p.getProperty("model"));
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class ExceptionViewProcessorTest method testAbsoluteExplicitTemplate.
@Test
public void testAbsoluteExplicitTemplate() throws IOException {
final Invocation.Builder request = target("/does-not-exist").request();
Response cr = request.get(Response.class);
assertEquals(404, cr.getStatus());
Properties p = new Properties();
p.load(cr.readEntity(InputStream.class));
assertEquals("/org/glassfish/jersey/tests/e2e/server/mvc/ExceptionViewProcessorTest/404.testp", p.getProperty("path"));
assertEquals("404", p.getProperty("model"));
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class EventListenerTest method testApplicationEvents.
@Test
public void testApplicationEvents() {
assertNotNull(applicationEventListener.appEventInitStart);
assertNotNull(applicationEventListener.appEventInitFinished);
assertEquals(APPLICATION_NAME, applicationEventListener.appEventInitStart.getResourceConfig().getApplicationName());
assertNull(applicationEventListener.newRequestEvent);
final Response response = target().path("resource").request().get();
assertEquals(200, response.getStatus());
assertNotNull(applicationEventListener.newRequestEvent);
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class EventListenerTest method testMatchedMethod.
@Test
public void testMatchedMethod() {
final Response response = target().path("resource").request().get();
assertEquals(200, response.getStatus());
assertEquals("get", response.readEntity(String.class));
assertEquals("[getMethod]", response.getHeaderString("R.RESOURCE_METHOD_START.method"));
assertEquals("[ok]", response.getHeaderString("R.RESOURCE_METHOD_FINISHED"));
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class EventListenerTest method testAsyncProcessingWithOneThread.
@Test
public void testAsyncProcessingWithOneThread() throws InterruptedException {
final Response response = target().path("resource/asyncOneThread").request().get();
assertEquals(200, response.getStatus());
assertEquals("async", response.readEntity(String.class));
int i = 1;
System.out.println(response.getHeaders());
assertEquals("[" + i++ + "]", response.getHeaderString("R.REQ_FILTERS_START.order"));
assertEquals("[" + i++ + "]", response.getHeaderString("R.REQ_FILTERS_FINISHED.order"));
assertEquals("[" + i++ + "]", response.getHeaderString("R.RESOURCE_METHOD_START.order"));
assertEquals("[" + i++ + "]", response.getHeaderString("R.RESP_FILTERS_START.order"));
assertEquals("[" + i + "]", response.getHeaderString("R.RESP_FILTERS_FINISHED.order"));
final boolean success = applicationEventListener.finishedCalled.await(3 * getAsyncTimeoutMultiplier(), TimeUnit.SECONDS);
Assert.assertTrue(success);
}
Aggregations