use of com.sun.jersey.api.client.ClientResponse in project photon-core by 1000Memories.
the class PhotoResourceTest method testNoModifications.
@Test
public void testNoModifications() throws Exception {
when(photoProvider.getPhotoInputStream("mf.jpg")).thenReturn(getImage("mf.jpg"));
ClientResponse response = client().resource("/mf.jpg").get(ClientResponse.class);
assertThat(response.getEntity(byte[].class), is(ByteStreams.toByteArray(getImage("mf.jpg"))));
assertThat(response.getType().toString(), is("image/jpeg"));
}
use of com.sun.jersey.api.client.ClientResponse in project hadoop by apache.
the class TestRMWithCSRFFilter method testAllowNonBrowserInteractionWithoutHeader.
@Test
public void testAllowNonBrowserInteractionWithoutHeader() throws Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("info").accept("application/xml").get(ClientResponse.class);
assertTrue("Should have been accepted", response.getStatus() == Status.OK.getStatusCode());
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
String xml = response.getEntity(String.class);
verifyClusterInfoXML(xml);
}
use of com.sun.jersey.api.client.ClientResponse in project hadoop by apache.
the class TestRMWithXFSFilter method testSameOrigin.
@Test
public void testSameOrigin() throws Exception {
createInjector("SAMEORIGIN");
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("info").accept("application/xml").get(ClientResponse.class);
assertTrue("Should have received SAMEORIGIN x-frame options header", response.getHeaders().get(XFrameOptionsFilter.X_FRAME_OPTIONS).get(0).equals("SAMEORIGIN"));
}
use of com.sun.jersey.api.client.ClientResponse in project hadoop by apache.
the class TestRMWithXFSFilter method testExplicitlyDisabled.
@Test
public void testExplicitlyDisabled() throws Exception {
createInjector(null, true);
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("info").accept("application/xml").get(ClientResponse.class);
assertFalse("Should have not received x-frame options header", response.getHeaders().get(XFrameOptionsFilter.X_FRAME_OPTIONS) == null);
}
use of com.sun.jersey.api.client.ClientResponse in project hadoop by apache.
the class TestRMWebServicesReservation method testListReservationHelper.
private JSONObject testListReservationHelper(WebResource resource, Status status) throws Exception {
Thread.sleep(1000);
ClientResponse response = resource.get(ClientResponse.class);
if (!this.isAuthenticationEnabled()) {
assertResponseStatusCode(Status.UNAUTHORIZED, response.getStatusInfo());
return null;
}
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
assertResponseStatusCode(status, response.getStatusInfo());
return response.getEntity(JSONObject.class);
}
Aggregations