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

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


            +TEST_RESOURCE_NAME+" via Classpath!",testURL);
    }
   
    @Test(expected=IllegalArgumentException.class)
    public void missingReferenceString(){
        new UrlReference((String)null);
    }
View Full Code Here


    public void missingReferenceString(){
        new UrlReference((String)null);
    }
    @Test(expected=IllegalArgumentException.class)
    public void missingReferenceURL(){
        new UrlReference((URL)null);
    }
View Full Code Here

    public void missingReferenceURL(){
        new UrlReference((URL)null);
    }
    @Test(expected=IllegalArgumentException.class)
    public void emptyReferenceString(){
        new UrlReference("");
    }
View Full Code Here

    public void emptyReferenceString(){
        new UrlReference("");
    }
    @Test(expected=IllegalArgumentException.class)
    public void relativeReferenceString(){
        new UrlReference("relative/path/to/some.resource");
    }
View Full Code Here

    public void relativeReferenceString(){
        new UrlReference("relative/path/to/some.resource");
    }
    @Test(expected=IllegalArgumentException.class)
    public void unknownProtocolReferenceString(){
        new UrlReference("unknownProt://test.example.org/some.resource");
    }
View Full Code Here

        new UrlReference("unknownProt://test.example.org/some.resource");
    }

    @Test
    public void testUrlReference() throws IOException{
        ContentReference ref = new UrlReference(testURL);
        assertNotNull(ref);
        assertEquals(ref.getReference(), testURL.toString());
        ContentSource source = ref.dereference();
        assertNotNull(source);
        String content = IOUtils.toString(source.getStream(), "UTF-8");
        assertNotNull(content);
        assertEquals(TEST_RESOURCE_CONTENT, content);

        //same as above, but by using ContentSource.getData() instead of
        //ContentSource.getStream()
        ref = new UrlReference(testURL);
        assertNotNull(ref);
        assertEquals(ref.getReference(), testURL.toString());
        source = ref.dereference();
        assertNotNull(source);
        content = new String(source.getData(),"UTF-8");
        assertNotNull(content);
        assertEquals(TEST_RESOURCE_CONTENT, content);

        //test the constructor that takes a String
        ref = new UrlReference(testURL.toString());
        assertNotNull(ref);
        assertEquals(ref.getReference(), testURL.toString());
        source = ref.dereference();
        assertNotNull(source);
        content = IOUtils.toString(source.getStream(), "UTF-8");
        assertNotNull(content);
        assertEquals(TEST_RESOURCE_CONTENT, content);
    }
View Full Code Here

TOP

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

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.