List of usage examples for org.apache.http.util EntityUtils consumeQuietly
public static void consumeQuietly(HttpEntity httpEntity)
From source file:org.fcrepo.test.api.TestRESTAPI.java
@Test public void testGETMethodBuiltInNoArg() throws Exception { URI url = getURI(/*from ww w.ja v a 2 s .c o m*/ String.format("/objects/%s/methods/fedora-system:3/viewMethodIndex", DEMO_REST_PID.toString())); verifyNoAuthFailOnAPIAAuth(url); HttpGet get = new HttpGet(url); HttpResponse response; int status = 0; response = getOrDelete(get, getAuthAccess(), false); status = response.getStatusLine().getStatusCode(); EntityUtils.consumeQuietly(response.getEntity()); assertEquals(SC_OK, status); }
From source file:org.fcrepo.test.api.TestRESTAPI.java
@Test public void testGETMethodCustomBadMethod() throws Exception { URI url = getURI("/objects/demo:14/methods/demo:12/noSuchMethod"); verifyNoAuthFailOnAPIAAuth(url);/*from ww w . j av a2 s . c o m*/ HttpGet get = new HttpGet(url); HttpResponse response; int status = 0; response = getOrDelete(get, getAuthAccess(), false); status = response.getStatusLine().getStatusCode(); EntityUtils.consumeQuietly(response.getEntity()); assertFalse(SC_OK == status); }
From source file:org.apache.olingo.server.example.TripPinServiceTest.java
@Test public void testCreateEntityWithLinkToRelatedEntities() throws Exception { String payload = "{\n" + " \"UserName\":\"olingo\",\n" + " \"FirstName\":\"Olingo\",\n" + " \"LastName\":\"Apache\",\n" + " \"Emails\":[\n" + " \"olingo@apache.org\"\n" + " ],\n" + " \"AddressInfo\":[\n" + " {\n" + " \"Address\":\"100 apache Ln.\",\n" + " \"City\":{\n" + " \"CountryRegion\":\"United States\",\n" + " \"Name\":\"Boise\",\n" + " \"Region\":\"ID\"\n" + " }\n" + " }\n" + " ],\n" + " \"Gender\":\"0\",\n" + " \"Concurrency\":635585295719432047,\n" + "\"Friends@odata.bind\":[\"" + baseURL + "/People('russellwhyte')\",\"" + baseURL + "/People('scottketchum')\"" + "]" + "}"; HttpPost postRequest = new HttpPost(baseURL + "/People"); postRequest.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON)); postRequest.setHeader("Prefer", "return=minimal"); HttpResponse response = httpSend(postRequest, 204); EntityUtils.consumeQuietly(response.getEntity()); response = httpGET(baseURL + "/People('olingo')/Friends", 200); JsonNode node = getJSONNode(response); assertEquals("$metadata#People", node.get("@odata.context").asText()); assertTrue(node.get("value").isArray()); assertEquals("scottketchum", ((ArrayNode) node.get("value")).get(1).get("UserName").asText()); }
From source file:org.fcrepo.test.api.TestRESTAPI.java
@Test public void testGETMethodCustomBadUserArg() throws Exception { URI url = getURI("/objects/demo:14/methods/demo:12/getDocumentStyle1?noSuchArg=foo"); verifyNoAuthFailOnAPIAAuth(url);//from ww w . j ava 2s . co m HttpGet get = new HttpGet(url); HttpResponse response = getOrDelete(get, getAuthAccess(), false); int status = response.getStatusLine().getStatusCode(); EntityUtils.consumeQuietly(response.getEntity()); assertFalse(SC_OK == status); }
From source file:org.fcrepo.test.api.TestRESTAPI.java
@Test public void testGETMethodCustomNoArg() throws Exception { URI url = getURI("/objects/demo:14/methods/demo:12/getDocumentStyle1"); verifyNoAuthFailOnAPIAAuth(url);/*from w ww.j a v a2 s.c om*/ HttpGet get = new HttpGet(url); HttpResponse response; int status = 0; response = getOrDelete(get, getAuthAccess(), false); status = response.getStatusLine().getStatusCode(); EntityUtils.consumeQuietly(response.getEntity()); assertEquals(SC_OK, status); }
From source file:org.apache.olingo.server.example.TripPinServiceTest.java
@Test public void testUpdatePrimitiveProperty() throws Exception { String payload = "{" + " \"value\":\"Pilar Ackerman\"" + "}"; String editUrl = baseURL + "/People('russellwhyte')/FirstName"; HttpPut postRequest = new HttpPut(editUrl); postRequest.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON)); HttpResponse response = httpSend(postRequest, 204); EntityUtils.consumeQuietly(response.getEntity()); response = httpGET(editUrl, 200);// w w w.j a v a2s . c o m JsonNode node = getJSONNode(response); assertEquals("$metadata#People('russellwhyte')/FirstName", node.get("@odata.context").asText()); assertEquals("Pilar Ackerman", node.get("value").asText()); }
From source file:org.fcrepo.test.api.TestRESTAPI.java
@Test public void testGETMethodCustomGoodUserArg() throws Exception { URI url = getURI("/objects/demo:29/methods/demo:27/resizeImage?width=50"); verifyNoAuthFailOnAPIAAuth(url);/*from w ww . j a v a2 s. c o m*/ HttpGet get = new HttpGet(url); HttpResponse response; int status = 0; response = getOrDelete(get, getAuthAccess(), true); status = response.getStatusLine().getStatusCode(); EntityUtils.consumeQuietly(response.getEntity()); assertEquals(SC_OK, status); // imageManip service does not return content length //assertEquals(1486, response.getResponseBody().length); //assertEquals("1486", response.getResponseHeader("Content-Length").getValue()); assertEquals("image/jpeg", response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue()); }
From source file:org.apache.olingo.server.example.TripPinServiceTest.java
@Test public void testUpdatePrimitiveArrayProperty() throws Exception { String payload = "{" + " \"value\": [\n" + " \"olingo@apache.com\"\n" + " ]" + "}"; String editUrl = baseURL + "/People('russellwhyte')/Emails"; HttpPut postRequest = new HttpPut(editUrl); postRequest.setEntity(new StringEntity(payload, ContentType.APPLICATION_JSON)); HttpResponse response = httpSend(postRequest, 204); EntityUtils.consumeQuietly(response.getEntity()); response = httpGET(editUrl, 200);/* ww w. j a v a 2s . c o m*/ JsonNode node = getJSONNode(response); assertEquals("$metadata#People('russellwhyte')/Emails", node.get("@odata.context").asText()); assertTrue(node.get("value").isArray()); assertEquals("olingo@apache.com", ((ArrayNode) node.get("value")).get(0).asText()); }
From source file:org.fcrepo.test.api.TestRESTAPI.java
@Test public void testGETMethodCustomGoodUserArgGoodDate() throws Exception { URI url = getURI("/objects/demo:29/methods/demo:27/resizeImage?width=50&asOfDateTime=" + datetime); verifyNoAuthFailOnAPIAAuth(url);//from ww w. j a v a2 s . co m HttpGet get = new HttpGet(url); HttpResponse response; int status = 0; response = getOrDelete(get, getAuthAccess(), true); status = response.getStatusLine().getStatusCode(); EntityUtils.consumeQuietly(response.getEntity()); assertEquals(SC_OK, status); // imageManip service does not return content length //assertEquals(1486, response.getResponseBody().length); //assertEquals("1486", response.getResponseHeader("Content-Length").getValue()); assertEquals("image/jpeg", response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue()); }