Search in sources :

Example 41 with InputStreamEntity

use of org.apache.http.entity.InputStreamEntity in project stanbol by apache.

the class EngineEnhancementRequestTest method testTikaMetadata.

/**
     * Tests an normal enhancement request directed to the tika engine 
     * @throws Exception
     */
@Test
public void testTikaMetadata() throws Exception {
    InputStream in = EngineEnhancementRequestTest.class.getClassLoader().getResourceAsStream("testJPEG_EXIF.jpg");
    Assert.assertNotNull("Unable to find test resource 'testJPEG_EXIF.jpg'", in);
    executor.execute(builder.buildPostRequest(getEndpoint() + "/engine/tika").withHeader("Accept", "text/rdf+nt").withEntity(new InputStreamEntity(in, -1))).assertStatus(200).assertContentRegexp(//only that the Enhancer REST API works also with engines!
    "<http://purl.org/dc/terms/format> \"image/jpeg\"", "<http://www.w3.org/ns/ma-ont#hasKeyword> \"serbor\"", "<http://www.semanticdesktop.org/ontologies/2007/05/10/nexif#isoSpeedRatings> \"400\"");
}
Also used : InputStream(java.io.InputStream) InputStreamEntity(org.apache.http.entity.InputStreamEntity) Test(org.junit.Test)

Aggregations

InputStreamEntity (org.apache.http.entity.InputStreamEntity)41 ByteArrayInputStream (java.io.ByteArrayInputStream)15 HttpPost (org.apache.http.client.methods.HttpPost)14 HttpResponse (org.apache.http.HttpResponse)12 InputStream (java.io.InputStream)10 Test (org.junit.Test)10 HttpEntity (org.apache.http.HttpEntity)8 IOException (java.io.IOException)7 HttpPut (org.apache.http.client.methods.HttpPut)7 Map (java.util.Map)4 HttpEntityEnclosingRequest (org.apache.http.HttpEntityEnclosingRequest)4 HttpClient (org.apache.http.client.HttpClient)4 StringEntity (org.apache.http.entity.StringEntity)4 BasicHttpResponse (org.apache.http.message.BasicHttpResponse)4 URISyntaxException (java.net.URISyntaxException)3 HashMap (java.util.HashMap)3 Header (org.apache.http.Header)3 ProtocolVersion (org.apache.http.ProtocolVersion)3 HttpGet (org.apache.http.client.methods.HttpGet)3 BasicHttpEntityEnclosingRequest (org.apache.http.message.BasicHttpEntityEnclosingRequest)3