List of usage examples for org.apache.http.entity ContentType APPLICATION_SVG_XML
ContentType APPLICATION_SVG_XML
To view the source code for org.apache.http.entity ContentType APPLICATION_SVG_XML.
Click Source Link
From source file:org.elasticsearch.client.RestHighLevelClientTests.java
public void testParseEntity() throws IOException { {//from w w w. ja va2 s . c o m IllegalStateException ise = expectThrows(IllegalStateException.class, () -> restHighLevelClient.parseEntity(null, null)); assertEquals("Response body expected but not returned", ise.getMessage()); } { IllegalStateException ise = expectThrows(IllegalStateException.class, () -> restHighLevelClient.parseEntity(new StringEntity("", (ContentType) null), null)); assertEquals("Elasticsearch didn't return the [Content-Type] header, unable to parse response body", ise.getMessage()); } { StringEntity entity = new StringEntity("", ContentType.APPLICATION_SVG_XML); IllegalStateException ise = expectThrows(IllegalStateException.class, () -> restHighLevelClient.parseEntity(entity, null)); assertEquals("Unsupported Content-Type: " + entity.getContentType().getValue(), ise.getMessage()); } { CheckedFunction<XContentParser, String, IOException> entityParser = parser -> { assertEquals(XContentParser.Token.START_OBJECT, parser.nextToken()); assertEquals(XContentParser.Token.FIELD_NAME, parser.nextToken()); assertTrue(parser.nextToken().isValue()); String value = parser.text(); assertEquals(XContentParser.Token.END_OBJECT, parser.nextToken()); return value; }; HttpEntity jsonEntity = new StringEntity("{\"field\":\"value\"}", ContentType.APPLICATION_JSON); assertEquals("value", restHighLevelClient.parseEntity(jsonEntity, entityParser)); HttpEntity yamlEntity = new StringEntity("---\nfield: value\n", ContentType.create("application/yaml")); assertEquals("value", restHighLevelClient.parseEntity(yamlEntity, entityParser)); HttpEntity smileEntity = createBinaryEntity(SmileXContent.contentBuilder(), ContentType.create("application/smile")); assertEquals("value", restHighLevelClient.parseEntity(smileEntity, entityParser)); HttpEntity cborEntity = createBinaryEntity(CborXContent.contentBuilder(), ContentType.create("application/cbor")); assertEquals("value", restHighLevelClient.parseEntity(cborEntity, entityParser)); } }
From source file:com.rackspacecloud.blueflood.inputs.handlers.HttpHandlerIntegrationTest.java
@Test public void testIngestWithContentTypeNonJsonShouldReturn415() throws Exception { HttpResponse response = httpPost(TENANT_ID, postPath, "random text", ContentType.APPLICATION_SVG_XML); assertEquals("content-type non Json should get 415", 415, response.getStatusLine().getStatusCode()); }
From source file:com.rackspacecloud.blueflood.inputs.handlers.HttpHandlerIntegrationTest.java
@Test public void testIngestMultiWithContentTypeNonJsonShouldReturn415() throws Exception { HttpResponse response = httpPost(TENANT_ID, postMultiPath, "random text", ContentType.APPLICATION_SVG_XML); assertEquals("content-type non Json should get 415", 415, response.getStatusLine().getStatusCode()); }
From source file:com.rackspacecloud.blueflood.inputs.handlers.HttpHandlerIntegrationTest.java
@Test public void testIngestAggregatedWithContentTypeNonJsonShouldReturn415() throws Exception { HttpResponse response = httpPost(TENANT_ID, postAggregatedPath, "random text", ContentType.APPLICATION_SVG_XML); assertEquals("content-type non Json should get 415", 415, response.getStatusLine().getStatusCode()); }
From source file:com.rackspacecloud.blueflood.inputs.handlers.HttpHandlerIntegrationTest.java
@Test public void testIngestAggregatedMultiWithContentTypeNonJsonShouldReturn415() throws Exception { HttpResponse response = httpPost(TENANT_ID, postAggregatedMultiPath, "random text", ContentType.APPLICATION_SVG_XML); assertEquals("content-type non Json should get 415", 415, response.getStatusLine().getStatusCode()); }
From source file:com.rackspacecloud.blueflood.inputs.handlers.HttpHandlerIntegrationTest.java
@Test public void testIngestEventWithContentTypeNonJsonShouldReturn415() throws Exception { HttpResponse response = httpPost(TENANT_ID, postEventsPath, "random text", ContentType.APPLICATION_SVG_XML); assertEquals("content-type non Json should get 415", 415, response.getStatusLine().getStatusCode()); }