KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > n3 > test > N3ExternalTests


1 /*
2  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

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 //import com.hp.hpl.jena.common.* ;
14
//import com.hp.hpl.jena.mem.* ;
15

16 /**
17  * @author Andy Seaborne
18  * @version $Id: N3ExternalTests.java,v 1.7 2005/02/21 12:04:07 andy_seaborne Exp $
19  */

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 JavaDoc filename)
29     {
30         super("N3 Parser tests", filename) ;
31     }
32
33     protected void makeTest(String JavaDoc n3File, String JavaDoc resultsFile)
34     {
35         String JavaDoc 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 JavaDoc n3File = null ;
50         String JavaDoc resultsFile = null ;
51         Reader rData = null ;
52         
53         Test(String JavaDoc testName, String JavaDoc _n3File, String JavaDoc _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 JavaDoc
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 JavaDoc s = r.readLine(); s != null ; s = r.readLine())
79                         pw.println(s) ;
80                     pw.println("+++++++") ;
81                     pw.flush() ;
82                 }
83
84             } catch (Exception JavaDoc ex)
85             {
86                 // @@CLEANUP
87
throw new JenaException(ex) ;
88             }
89         }
90     }
91 }
92
93 /*
94  * (c) Copyright 2001, 2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP
95  * All rights reserved.
96  *
97  * Redistribution and use in source and binary forms, with or without
98  * modification, are permitted provided that the following conditions
99  * are met:
100  * 1. Redistributions of source code must retain the above copyright
101  * notice, this list of conditions and the following disclaimer.
102  * 2. Redistributions in binary form must reproduce the above copyright
103  * notice, this list of conditions and the following disclaimer in the
104  * documentation and/or other materials provided with the distribution.
105  * 3. The name of the author may not be used to endorse or promote products
106  * derived from this software without specific prior written permission.
107  *
108  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
109  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
110  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
111  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
112  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
113  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
114  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
115  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
116  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
117  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
118  */

119
Popular Tags