Package com.ontology2.rdf.parser

Source Code of com.ontology2.rdf.parser.NodeParserTest

package com.ontology2.rdf.parser;

import static org.junit.Assert.*;

import java.io.StringReader;

import org.junit.Test;

import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Node_URI;
import com.hp.hpl.jena.vocabulary.XSD;
import com.ontology2.rdf.parser.TokenMgrError;

public class NodeParserTest {

    @Test
    public void testXRI() throws ParseException {
        NodeParser n=new NodeParser(new StringReader("<http://ookaboo.com/>"));
        n.parse();
        Node node=n.getNodeValue();
        assert(null!=node);
        assert(node instanceof Node_URI);
        assertEquals("http://ookaboo.com/",node.getURI());
    }

    @Test
    public void testInt() throws ParseException {
        NodeParser n=new NodeParser(new StringReader("55"));
        n.parse();
        Node node=n.getNodeValue();
        assert(null!=node);
        assert(node.isLiteral());
        assertEquals(XSDDatatype.XSDinteger,node.getLiteralDatatype());
        assertEquals(55,node.getLiteralValue());
    }

    @Test(expected=TokenMgrError.class)
    public void testCrash() throws ParseException {
        NodeParser n=new NodeParser(new StringReader("<not http://a.uri/ by a>>ny means>"));
        n.parse();
    }
}
TOP

Related Classes of com.ontology2.rdf.parser.NodeParserTest

TOP
Copyright © 2018 www.massapi.com. 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.