001: /*
002: * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * [See end of file]
004: */
005:
006: package com.hp.hpl.jena.n3.test;
007:
008: import java.io.*;
009: import com.hp.hpl.jena.n3.*;
010: import junit.framework.*;
011:
012: import com.hp.hpl.jena.shared.*;
013:
014: //import com.hp.hpl.jena.common.* ;
015: //import com.hp.hpl.jena.mem.* ;
016:
017: /**
018: * @author Andy Seaborne
019: * @version $Id: N3ExternalTests.java,v 1.10 2008/01/02 12:06:53 andy_seaborne Exp $
020: */
021: public class N3ExternalTests extends N3ExternalTestsCom {
022: static public boolean VERBOSE = false;
023:
024: public N3ExternalTests() {
025: this ("n3-parser-tests");
026: }
027:
028: public N3ExternalTests(String filename) {
029: super ("N3 Parser tests", filename);
030: }
031:
032: protected void makeTest(String n3File, String resultsFile) {
033: String testName = n3File + "::" + resultsFile;
034:
035: if (basedir != null)
036: n3File = basedir + "/" + n3File;
037:
038: if (basedir != null && resultsFile != null
039: && !resultsFile.equals(""))
040: resultsFile = basedir + "/" + resultsFile;
041:
042: addTest(new Test(testName, n3File, basedir + "/" + resultsFile));
043: }
044:
045: static class Test extends TestCase {
046: N3Parser parser = null;
047: String n3File = null;
048: String resultsFile = null;
049: Reader rData = null;
050:
051: Test(String testName, String _n3File, String _resultsFile) {
052: super ("N3 Parser test: " + testName);
053: n3File = _n3File;
054: resultsFile = _resultsFile;
055: try {
056: rData = new FileReader(n3File);
057: parser = new N3Parser(new BufferedReader(rData),
058: new NullN3EventHandler());
059: } catch (IOException ioEx) {
060: System.err.println("IO Exception: " + ioEx);
061: }
062: }
063:
064: protected void runTest() throws Throwable {
065: try {
066: parser.parse();
067: if (VERBOSE) {
068: PrintWriter pw = new PrintWriter(System.out);
069:
070: BufferedReader r = new BufferedReader(
071: new FileReader(n3File));
072: pw.println("+++++++ " + this .getName());
073: for (String s = r.readLine(); s != null; s = r
074: .readLine())
075: pw.println(s);
076: pw.println("+++++++");
077: pw.flush();
078: }
079:
080: } catch (Exception ex) {
081: // @@CLEANUP
082: throw new JenaException(ex);
083: }
084: }
085: }
086: }
087:
088: /*
089: * (c) Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
090: * All rights reserved.
091: *
092: * Redistribution and use in source and binary forms, with or without
093: * modification, are permitted provided that the following conditions
094: * are met:
095: * 1. Redistributions of source code must retain the above copyright
096: * notice, this list of conditions and the following disclaimer.
097: * 2. Redistributions in binary form must reproduce the above copyright
098: * notice, this list of conditions and the following disclaimer in the
099: * documentation and/or other materials provided with the distribution.
100: * 3. The name of the author may not be used to endorse or promote products
101: * derived from this software without specific prior written permission.
102: *
103: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
104: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
105: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
106: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
107: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
108: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
109: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
110: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
112: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113: */
|