use of javax.ws.rs.core.Response in project jersey by jersey.
the class ImplicitProducesViewProcessorTest method testImplicitTemplate.
@Test
public void testImplicitTemplate() throws IOException {
final WebTarget target = target("implicit");
Properties p = new Properties();
Response cr = target.request("text/plain", "application/foo").get(Response.class);
assertEquals(MediaType.TEXT_PLAIN_TYPE, cr.getMediaType());
p.load(cr.readEntity(InputStream.class));
assertEquals("/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitProducesViewProcessorTest/ImplicitTemplate/index.testp", p.getProperty("path"));
assertEquals("ImplicitTemplate", p.getProperty("model"));
p = new Properties();
cr = target.request("application/foo", "text/plain").get(Response.class);
assertEquals(MediaType.TEXT_PLAIN_TYPE, cr.getMediaType());
p.load(cr.readEntity(InputStream.class));
assertEquals("/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitProducesViewProcessorTest/ImplicitTemplate/index.testp", p.getProperty("path"));
assertEquals("ImplicitTemplate", p.getProperty("model"));
p = new Properties();
cr = target.request("text/plain;q=0.5", "application/foo").get(Response.class);
assertEquals(MediaType.TEXT_PLAIN_TYPE, cr.getMediaType());
p.load(cr.readEntity(InputStream.class));
assertEquals("/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitProducesViewProcessorTest/ImplicitTemplate/index.testp", p.getProperty("path"));
assertEquals("ImplicitTemplate", p.getProperty("model"));
p = new Properties();
cr = target.request("application/foo", "text/plain;q=0.5").get(Response.class);
assertEquals(MediaType.TEXT_PLAIN_TYPE, cr.getMediaType());
p.load(cr.readEntity(InputStream.class));
assertEquals("/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitProducesViewProcessorTest/ImplicitTemplate/index.testp", p.getProperty("path"));
assertEquals("ImplicitTemplate", p.getProperty("model"));
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class ImplicitViewWithResourceFilterTest method testImplicitTemplate.
@Test
public void testImplicitTemplate() throws IOException {
final Invocation.Builder request = target("/").request();
Response cr = request.get(Response.class);
assertEquals(200, cr.getStatus());
List<Object> xTest = cr.getMetadata().get("X-TEST");
assertEquals(2, xTest.size());
assertEquals("two", xTest.get(1));
assertEquals("one", xTest.get(0));
Properties p = new Properties();
p.load(cr.readEntity(InputStream.class));
assertEquals("/org/glassfish/jersey/tests/e2e/server/mvc/ImplicitViewWithResourceFilterTest/ImplicitTemplate/index.testp", p.getProperty("path"));
assertEquals("ImplicitTemplate", p.getProperty("model"));
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class BasicValidationTest method testInputParamsCustomConstraintsPositive.
@Test
public void testInputParamsCustomConstraintsPositive() throws Exception {
final Response response = testInputParams("customParam", getDefaultParamBean());
assertEquals(200, response.getStatus());
assertEquals("pathParam_matrixParam_queryParam_headerParam_cookieParam_formParam", response.readEntity(String.class));
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class BasicValidationTest method testCustomBeanParamNegative.
@Test
public void testCustomBeanParamNegative() throws Exception {
final ContactBean contactBean = new ContactBean();
contactBean.setEmail("jersey@example.com");
contactBean.setPhone("134539");
final Response response = testBean("customBeanParam", contactBean);
assertEquals(400, response.getStatus());
final String message = response.readEntity(String.class);
assertTrue(message.contains("arg0"));
}
use of javax.ws.rs.core.Response in project jersey by jersey.
the class BasicValidationTest method testValidBeanWrappedInResponsePositive.
@Test
public void testValidBeanWrappedInResponsePositive() throws Exception {
final ContactBean contactBean = new ContactBean();
contactBean.setName("Jersey");
contactBean.setEmail("jersey@example.com");
final Response response = testBean("validBeanWrappedInResponse", contactBean);
assertEquals(contactBean, response.readEntity(ContactBean.class));
}
Aggregations