01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.rio.ntriples;
07:
08: import java.io.InputStream;
09:
10: import junit.framework.TestCase;
11:
12: import org.openrdf.rio.RDFParseException;
13: import org.openrdf.rio.RDFParser;
14: import org.openrdf.rio.helpers.RDFHandlerBase;
15:
16: /**
17: * JUnit test for the N-Triples parser.
18: *
19: * @author Arjohn Kampman
20: */
21: public class NTriplesParserTest extends TestCase {
22:
23: /*-----------*
24: * Constants *
25: *-----------*/
26:
27: private static String NTRIPLES_TEST_URL = "http://www.w3.org/2000/10/rdf-tests/rdfcore/ntriples/test.nt";
28:
29: private static String NTRIPLES_TEST_FILE = "/testcases/ntriples/test.nt";
30:
31: /*---------*
32: * Methods *
33: *---------*/
34:
35: public void testNTriplesFile() throws Exception {
36: NTriplesParser turtleParser = new NTriplesParser();
37: turtleParser
38: .setDatatypeHandling(RDFParser.DatatypeHandling.IGNORE);
39: turtleParser.setRDFHandler(new RDFHandlerBase());
40:
41: InputStream in = NTriplesParser.class
42: .getResourceAsStream(NTRIPLES_TEST_FILE);
43: try {
44: turtleParser.parse(in, NTRIPLES_TEST_URL);
45: } catch (RDFParseException e) {
46: fail("Failed to parse N-Triples test document: "
47: + e.getMessage());
48: } finally {
49: in.close();
50: }
51: }
52: }
|