1 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 41 public class testNTripleReader extends Object { 42 43 44 protected static void doTest(Model m1) { 45 (new testNTripleReader()).test(m1); 46 } 47 48 protected static Log logger = LogFactory.getLog( testNTripleReader.class ); 49 50 void test(Model m1) { 51 52 String test = "testNTripleReader"; 53 String filebase = "modules/rdf/regression/" + test + "/"; 54 int n = 0; 56 try { 57 empty(m1); 58 n++; m1.read(ResourceReader.getInputStream(filebase + "1.nt"), "", "N-TRIPLE"); 59 if (m1.size() != 5) error(test, n); 60 StmtIterator iter = 61 m1.listStatements( null, null, "foo\"\\\n\r\tbar" ); 62 n++; if (! iter.hasNext()) error(test, n); 63 } catch (Exception e) { 64 inError = true; 65 logger.error( " test " + test + "[" + n + "]", e); 66 } 67 } 69 70 protected void empty(Model m) { 71 StmtIterator iter = m.listStatements(); 72 while (iter.hasNext()) { 73 iter.nextStatement(); 74 iter.remove(); 75 } 76 } 77 private boolean inError = false; 78 79 protected void error(String test, int n) { 80 System.out.println(test + ": failed test " + Integer.toString(n)); 81 inError = true; 82 } 83 84 public boolean getErrors() { 85 return inError; 86 } 87 88 } 89 | Popular Tags |