1 5 6 package com.hp.hpl.jena.n3.test; 7 8 import java.io.* ; 9 import com.hp.hpl.jena.n3.* ; 10 import junit.framework.* ; 11 12 import com.hp.hpl.jena.shared.*; 13 16 20 public class N3ExternalTests extends N3ExternalTestsCom 21 { 22 static public boolean VERBOSE = false ; 23 public N3ExternalTests() 24 { 25 this("n3-parser-tests") ; 26 } 27 28 public N3ExternalTests(String filename) 29 { 30 super("N3 Parser tests", filename) ; 31 } 32 33 protected void makeTest(String n3File, String resultsFile) 34 { 35 String testName = n3File + "::" + resultsFile ; 36 37 if ( basedir != null ) 38 n3File = basedir+"/"+n3File ; 39 40 if ( basedir != null && resultsFile != null && !resultsFile.equals("") ) 41 resultsFile = basedir + "/" + resultsFile ; 42 43 addTest(new Test(testName, n3File, basedir+"/"+resultsFile)) ; 44 } 45 46 static class Test extends TestCase 47 { 48 N3Parser parser = null ; 49 String n3File = null ; 50 String resultsFile = null ; 51 Reader rData = null ; 52 53 Test(String testName, String _n3File, String _resultsFile) 54 { 55 super("N3 Parser test: "+testName) ; 56 n3File = _n3File ; 57 resultsFile = _resultsFile ; 58 try { 59 rData = new FileReader(n3File) ; 60 parser = new N3Parser(new BufferedReader(rData), new NullN3EventHandler()) ; 61 } catch (IOException ioEx) 62 { 63 System.err.println("IO Exception: "+ioEx) ; 64 } 65 } 66 67 68 protected void runTest() throws Throwable 69 { 70 try { 71 parser.parse() ; 72 if ( VERBOSE ) 73 { 74 PrintWriter pw = new PrintWriter(System.out) ; 75 76 BufferedReader r = new BufferedReader(new FileReader(n3File)) ; 77 pw.println("+++++++ "+this.getName()) ; 78 for ( String s = r.readLine(); s != null ; s = r.readLine()) 79 pw.println(s) ; 80 pw.println("+++++++") ; 81 pw.flush() ; 82 } 83 84 } catch (Exception ex) 85 { 86 throw new JenaException(ex) ; 88 } 89 } 90 } 91 } 92 93 119 | Popular Tags |