01: /*
02: * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: * All rights reserved.
04: *
05: * Redistribution and use in source and binary forms, with or without
06: * modification, are permitted provided that the following conditions
07: * are met:
08: * 1. Redistributions of source code must retain the above copyright
09: * notice, this list of conditions and the following disclaimer.
10: * 2. Redistributions in binary form must reproduce the above copyright
11: * notice, this list of conditions and the following disclaimer in the
12: * documentation and/or other materials provided with the distribution.
13: * 3. The name of the author may not be used to endorse or promote products
14: * derived from this software without specific prior written permission.
15:
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26: *
27: * $Id: testNTripleReader.java,v 1.13 2008/01/02 12:07:03 andy_seaborne Exp $
28: */
29:
30: package com.hp.hpl.jena.regression;
31:
32: import com.hp.hpl.jena.rdf.model.*;
33: import org.apache.commons.logging.Log;
34: import org.apache.commons.logging.LogFactory;
35:
36: /**
37: *
38: * @author bwm
39: * @version $Revision: 1.13 $
40: */
41: public class testNTripleReader extends Object {
42:
43: protected static void doTest(Model m1) {
44: (new testNTripleReader()).test(m1);
45: }
46:
47: protected static Log logger = LogFactory
48: .getLog(testNTripleReader.class);
49:
50: void test(Model m1) {
51:
52: String test = "testNTripleReader";
53: String filebase = "testing/regression/" + test + "/";
54: // System.out.println("Beginning " + test);
55: int n = 0;
56: try {
57: empty(m1);
58: n++;
59: m1.read(ResourceReader.getInputStream(filebase + "1.nt"),
60: "", "N-TRIPLE");
61: if (m1.size() != 5)
62: error(test, n);
63: StmtIterator iter = m1.listStatements(null, null,
64: "foo\"\\\n\r\tbar");
65: n++;
66: if (!iter.hasNext())
67: error(test, n);
68: } catch (Exception e) {
69: inError = true;
70: logger.error(" test " + test + "[" + n + "]", e);
71: }
72: // System.out.println("End of " + test);
73: }
74:
75: protected void empty(Model m) {
76: StmtIterator iter = m.listStatements();
77: while (iter.hasNext()) {
78: iter.nextStatement();
79: iter.remove();
80: }
81: }
82:
83: private boolean inError = false;
84:
85: protected void error(String test, int n) {
86: System.out.println(test + ": failed test "
87: + Integer.toString(n));
88: inError = true;
89: }
90:
91: public boolean getErrors() {
92: return inError;
93: }
94:
95: }
|