001    /*
002     * (c) Copyright 2010 University of Bristol
003     * All rights reserved.
004     * [See end of file]
005     */
006    package net.rootdev.javardfa;
007    
008    import net.rootdev.javardfa.jena.JenaStatementSink;
009    import com.hp.hpl.jena.rdf.model.Model;
010    import com.hp.hpl.jena.rdf.model.ModelFactory;
011    import com.hp.hpl.jena.rdf.model.Resource;
012    import net.rootdev.javardfa.ParserFactory.Format;
013    import org.junit.Test;
014    import static org.junit.Assert.*;
015    import org.xml.sax.XMLReader;
016    
017    /**
018     * Note: most testing happens in conformance
019     * @author pldms
020     */
021    public class ParserTest {
022    
023        public ParserTest() {
024        }
025    
026        /**
027         * This bit me. html5 parser sets systemId rather late.
028         */
029        @Test
030        public void testBaseLocator() throws Exception {
031            Model m = ModelFactory.createDefaultModel();
032            StatementSink sink = new JenaStatementSink(m);
033            XMLReader parser = ParserFactory.createReaderForFormat(sink, Format.HTML);
034            parser.parse(this.getClass().getResource("/simple.html").toExternalForm());
035            Resource r = m.listSubjects().nextResource();
036            assertTrue("HTML 5 base correct", r.getURI().endsWith("simple.html"));
037        }
038    
039    }
040    
041    /*
042     * (c) Copyright 2010 University of Bristol
043     * All rights reserved.
044     *
045     * Redistribution and use in source and binary forms, with or without
046     * modification, are permitted provided that the following conditions
047     * are met:
048     * 1. Redistributions of source code must retain the above copyright
049     *    notice, this list of conditions and the following disclaimer.
050     * 2. Redistributions in binary form must reproduce the above copyright
051     *    notice, this list of conditions and the following disclaimer in the
052     *    documentation and/or other materials provided with the distribution.
053     * 3. The name of the author may not be used to endorse or promote products
054     *    derived from this software without specific prior written permission.
055     *
056     * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
057     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
058     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
059     * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
060     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
061     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
062     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
063     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
064     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
065     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
066     */