Package org.apache.stanbol.enhancer.servicesapi.impl

Examples of org.apache.stanbol.enhancer.servicesapi.impl.StreamSource


            Assert.assertTrue(e instanceof IllegalStateException);
        }
    }
    @Test
    public void checkDataFromStreamSource() throws IOException {
        ContentSource source = new StreamSource(new ByteArrayInputStream(DATA));
        Assert.assertTrue(Arrays.equals(DATA, source.getData()));
        //multiple calls must work
        source.getData();
    }
View Full Code Here


     * Tests checking correct handling of parameters and default values
     */
   
    @Test
    public void checkMediaTypeForStreamSource() throws IOException {
        ContentSource source = new StreamSource(new ByteArrayInputStream(DATA));
        assertEquals(DEFAULT_MT, source.getMediaType());
        source = new StreamSource(new ByteArrayInputStream(DATA),null);
        assertEquals(DEFAULT_MT, source.getMediaType());
        source = new StreamSource(new ByteArrayInputStream(DATA),null,HEADERS);
        assertEquals(DEFAULT_MT, source.getMediaType());
        source = new StreamSource(new ByteArrayInputStream(DATA),null,FILE_NAME,HEADERS);
        assertEquals(DEFAULT_MT, source.getMediaType());
       
        source = new StreamSource(new ByteArrayInputStream(DATA),MT);
        assertEquals(MT, source.getMediaType());
        source = new StreamSource(new ByteArrayInputStream(DATA),MT,HEADERS);
        assertEquals(MT, source.getMediaType());
        source = new StreamSource(new ByteArrayInputStream(DATA),MT,FILE_NAME,HEADERS);
        assertEquals(MT, source.getMediaType());
        //Parameters MUST BE preserved!
        source = new StreamSource(new ByteArrayInputStream(DATA),MT_WITH_PARAM);
        assertEquals(MT_WITH_PARAM, source.getMediaType());
        source = new StreamSource(new ByteArrayInputStream(DATA),MT_WITH_PARAM,HEADERS);
        assertEquals(MT_WITH_PARAM, source.getMediaType());
        source = new StreamSource(new ByteArrayInputStream(DATA),MT_WITH_PARAM,FILE_NAME,HEADERS);
        assertEquals(MT_WITH_PARAM, source.getMediaType());
    }
View Full Code Here

        assertEquals(ISO8859_4.name(), mt.get("charset"));
    }

    @Test
    public void checkFileName() throws IOException{
        ContentSource source = new StreamSource(new ByteArrayInputStream(DATA),null,null,null);
        assertNull(source.getFileName());

        source = new StreamSource(new ByteArrayInputStream(DATA),null,FILE_NAME,null);
        assertEquals(FILE_NAME, source.getFileName());
       
        source = new ByteArraySource(DATA,null,FILE_NAME);
        assertEquals(FILE_NAME, source.getFileName());
       
        source = new ByteArraySource(DATA,null,FILE_NAME,null);
        assertEquals(FILE_NAME, source.getFileName());
       
    }
View Full Code Here

       
    }

    @Test
    public void checkHeaders() throws IOException{
        ContentSource source = new StreamSource(new ByteArrayInputStream(DATA),null,null,null);
        assertNotNull(source.getHeaders());
        assertTrue(source.getHeaders().isEmpty());
        source = new StreamSource(new ByteArrayInputStream(DATA),null,null,HEADERS);
        assertEquals(HEADERS, source.getHeaders());
       
        source = new ByteArraySource(DATA,null,null,null);
        assertNotNull(source.getHeaders());
        assertTrue(source.getHeaders().isEmpty());
        source = new ByteArraySource(DATA,null,null,HEADERS);
        assertEquals(HEADERS, source.getHeaders());
    }
View Full Code Here

    @Before
    public void setupTest() throws IOException {
        //create a contentItem for the plain text used for testing
        InputStream is = FstLinkingEngineTest.class.getClassLoader().getResourceAsStream(TEST_TEXT_FILE);
        Assert.assertNotNull("Unable to load '"+TEST_TEXT_FILE+"' via classpath",is);
        ContentItem ci = cif.createContentItem(new StreamSource(is,"text/plain"));
        AnalysedText at = atf.createAnalysedText(ci, ci.getBlob());
        is.close();
        //parse the prepared NLP results and add it to the ContentItem
        is = FstLinkingEngineTest.class.getClassLoader().getResourceAsStream(TEST_TEXT_NLP_FILE);
        Assert.assertNotNull("Unable to load '"+TEST_TEXT_NLP_FILE+"' via classpath",is);
View Full Code Here

    }
   
    private ContentItem createContentItem(String resourceName, String contentType) throws IOException {
        InputStream in = TikaEngineTest.class.getClassLoader().getResourceAsStream(resourceName);
        assertNotNull(in);
        return ciFactory.createContentItem(new StreamSource(in,contentType));
    }
View Full Code Here

    }
   
    private ContentItem createContentItem(String resourceName, String contentType) throws IOException {
        InputStream in = TikaEngineTest.class.getClassLoader().getResourceAsStream(resourceName);
        assertNotNull(in);
        return ciFactory.createContentItem(new StreamSource(in,contentType));
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.enhancer.servicesapi.impl.StreamSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.