1 29 30 package com.hp.hpl.jena.regression; 31 32 import com.hp.hpl.jena.rdf.model.*; 33 import com.hp.hpl.jena.rdf.model.impl.*; 34 35 import java.net.*; 36 import java.io.*; 37 38 import com.hp.hpl.jena.shared.*; 39 40 import org.apache.commons.logging.Log; 41 import org.apache.commons.logging.LogFactory; 42 43 48 public class testReaderInterface extends Object { 49 50 51 protected static void doTest(Model m1) { 52 (new testReaderInterface()).test(m1); 53 } 54 55 protected static Log logger = LogFactory.getLog( testReaderInterface.class ); 56 57 void test(Model m1) { 58 59 String test = "testReaderInterface"; 60 String filebase = "modules/rdf/regression/" + test + "/"; 61 int n = 0; 63 try { 64 n++; RDFReader reader = m1.getReader(); 65 66 74 75 n++; reader = m1.getReader("N-TRIPLE"); 76 if (! (reader instanceof NTripleReader)) error(test, n); 77 78 n++; try { 79 m1.setReaderClassName("foobar", ""); 80 reader = m1.getReader("foobar"); 81 error(test, n); 82 } catch (NoReaderForLangException jx) { 83 } 85 86 n++; m1.setReaderClassName("foobar", 87 com.hp.hpl.jena.rdf.arp.JenaReader.class.getName()); 88 reader = m1.getReader("foobar"); 89 if (! (reader instanceof com.hp.hpl.jena.rdf.arp.JenaReader)) error(test, n); 90 91 try { 92 93 n++; m1.read("http://www.w3.org/2000/10/rdf-tests/rdfcore/" 94 + "rdf-containers-syntax-vs-schema/test001.rdf"); 95 96 n++; m1.read("http://www.w3.org/2000/10/rdf-tests/rdfcore/" 97 + "rdf-containers-syntax-vs-schema/test001.nt", 98 "N-TRIPLE"); 99 } catch (JenaException jx) 100 { 101 if (jx.getCause() instanceof NoRouteToHostException 102 || jx.getCause() instanceof UnknownHostException 103 || jx.getCause() instanceof ConnectException 104 || jx.getCause() instanceof IOException 105 ) 106 {logger.warn("Cannot access public internet - part of test not executed" ); 107 } 108 else 109 throw jx; 110 } 111 112 113 n++; m1.read(ResourceReader.getInputStream(filebase + "1.rdf"), "http://example.org/"); 114 115 n++; m1.read( 116 ResourceReader.getInputStream(filebase + "2.nt"), "", "N-TRIPLE"); 117 118 119 } catch (Exception e) { 120 inError = true; 121 logger.error( " test " + test + "[" + n + "]", e); 122 } 123 } 125 private boolean inError = false; 126 127 protected void error(String test, int n) { 128 System.out.println(test + ": failed test " + Integer.toString(n)); 129 inError = true; 130 } 131 132 public boolean getErrors() { 133 return inError; 134 } 135 136 } 137 | Popular Tags |