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

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


        }
        log.debug("Created ContentItem with id:{} and uri:{}", id, uri);
        final MGraph g = new IndexedMGraph();
        ContentItem ci = null;
        try {
            ci = ciFactory.createContentItem(uri, new ByteArraySource(content, contentType), g);
        } catch (IOException e) {
            log.error("Failed to create contentitem with uri: {}", uri.getUnicodeString());
            throw new StoreException(String.format("Failed to create contentitem with uri: %s",
                uri.getUnicodeString()));
        }
View Full Code Here


            }
        }
        ContentItem ci = null;
        try {
            ci = ciFactory
                    .createContentItem(new UriRef(id), new ByteArraySource(content, mimeType), metadata);
        } catch (IOException e) {
            log.error("Failed to create contentitem with uri: {}", id);
            throw new StoreException(String.format("Failed to create contentitem with uri: %s", id));
        }
        return ci;
View Full Code Here

                : new UriRef(id);
        log.debug("create ContentItem for id " + uri + " on TC Manager= "
                + tcProvider);
        final MGraph g = new IndexedMGraph();
        try {
            return ciFactory.createContentItem(uri, new ByteArraySource(content, mimeType), g);
        } catch (IOException e) {
            throw new IllegalStateException("IOException while creation of an in-memory" +
                "ContentItem (that should never happen)!",e);
        }
    }
View Full Code Here

    /**
     * Internally used to create {@link ContentSource} instanced for the
     * MimeType parsing tests
     */
    private static ContentSource createContentSource(String mimeType){
        return new ByteArraySource(content, mimeType);
    }
View Full Code Here

        Assert.assertEquals("text/plain", blob.getMimeType());
        Assert.assertTrue(blob.getParameter().containsKey("charset"));
        Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
        //2nd via a ByteArray
        byte[] data = test.getBytes(ISO8859_4);
        cs = new ByteArraySource(data,"text/plain; charset="+ISO8859_4.name());
        blob = createBlob(cs);
        Assert.assertEquals("text/plain", blob.getMimeType());
        Assert.assertTrue(blob.getParameter().containsKey("charset"));
        Assert.assertEquals(ISO8859_4.name(), blob.getParameter().get("charset"));
        //3rd as Stream
View Full Code Here

     * Tests the default mimeType "application/octet-stream" for binary data.
     * @throws IOException
     */
    @Test
    public void testDefaultBinaryMimeType() throws IOException {
        Blob blob = createBlob(new ByteArraySource("dummy".getBytes(UTF8)));
        Assert.assertEquals("application/octet-stream", blob.getMimeType());
        Assert.assertTrue(blob.getParameter().isEmpty());

        blob = createBlob(new StreamSource(new ByteArrayInputStream("dummy".getBytes(UTF8))));
        Assert.assertEquals("application/octet-stream", blob.getMimeType());
View Full Code Here

     * Tests ensuring the IllegalArgumentExceptions if null is parsed as
     * byte array to
     */
    @Test(expected=IllegalArgumentException.class)
    public void missingByteArray(){
        new ByteArraySource(null);
    }
View Full Code Here

    public void missingByteArray(){
        new ByteArraySource(null);
    }
    @Test(expected=IllegalArgumentException.class)
    public void missingByteArray1(){
        new ByteArraySource(null,MT);
    }
View Full Code Here

    public void missingByteArray1(){
        new ByteArraySource(null,MT);
    }
    @Test(expected=IllegalArgumentException.class)
    public void missingByteArray2(){
        new ByteArraySource(null,MT,FILE_NAME);
    }
View Full Code Here

    public void missingByteArray2(){
        new ByteArraySource(null,MT,FILE_NAME);
    }
    @Test(expected=IllegalArgumentException.class)
    public void missingByteArray3(){
        new ByteArraySource(null,MT,FILE_NAME,HEADERS);
    }
View Full Code Here

TOP

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

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.