1 32 33 package com.hp.hpl.jena.rdf.arp.test; 34 import junit.framework.TestSuite; 35 import junit.framework.Test; 36 import java.io.*; 37 import java.util.*; 38 39 import com.hp.hpl.jena.shared.wg.*; 40 46 public class ARPTests extends java.lang.Object { 47 53 static public boolean internet = false; 54 static URI wgTestDir = 55 URI.create("http://www.w3.org/2000/10/rdf-tests/rdfcore/"); 56 static URI arpTestDir = 57 URI.create("http://jcarroll.hpl.hp.com/arp-tests/"); 58 59 static public Test suite() { 60 TestSuite s = new TestSuite("ARP"); 61 if (internet) { 62 s.addTest(NTripleTestSuite.suite(wgTestDir, wgTestDir, "WG Parser Tests")); 63 } else { 64 s.addTest(WGTestSuite.suite(wgTestDir, "wg", 65 "WG Parser Tests")); 68 s.addTest(WGTestSuite.suite(arpTestDir, "arp", 69 "ARP Tests")); 72 s.addTest(NTripleTestSuite.suite(wgTestDir, "wg", 73 "NTriple WG Tests")); 76 } 77 return s; 78 } 79 static int cnt = 0; 80 static String toJava(Test s,PrintWriter pw, String wgparent) { 81 String name = "test"+cnt++; 82 if ( s instanceof TestSuite ) { 83 TestSuite ts = (TestSuite)s; 84 if ( s instanceof WGTestSuite ) { 85 pw.println("WGTestSuite "+name + " = " + ((WGTestSuite)s).createMe+";"); 86 wgparent = name; 87 } else { 88 pw.println("TestSuite "+name + " = new TestSuite(\""+ts.getName()+"\");"); 89 } 90 Enumeration ee = ts.tests(); 91 while ( ee.hasMoreElements() ) { 92 Test tt = (Test)ee.nextElement(); 93 if ( tt == null ) 94 continue; 95 String sub = toJava(tt,pw ,wgparent); 96 pw.println(name+".addTest("+sub+");"); 97 } 98 } 99 else if ( s instanceof WGTestSuite.Test ) { 100 String className = s.getClass().getName(); 101 String localPart = className.substring(className.lastIndexOf('$')+1); 102 pw.println("Test "+ name + " = " + wgparent +".create" + localPart +"(" 103 + ((WGTestSuite.Test)s).createMe() + ");"); 104 } 105 else { 106 pw.println(name + " is of class " + s.getClass().getName()); 107 } 108 109 110 return name; 111 } 112 static public void main(String args[]) throws IOException { 113 Test ts = suite(); 114 PrintWriter pw = new PrintWriter(new FileWriter("src/com/hp/hpl/jena/rdf/arp/test/TestPackage.java")); 115 pw.println("/*"); 116 pw.println(" * (c) Copyright 2002-2002, 2003, 2004, 2005 Hewlett-Packard Development Company, LP") ; 117 pw.println(" * All rights reserved."); 118 pw.println(" *"); 119 pw.println(" * Redistribution and use in source and binary forms, with or without"); 120 pw.println(" * modification, are permitted provided that the following conditions"); 121 pw.println(" * are met:"); 122 pw.println(" * 1. Redistributions of source code must retain the above copyright"); 123 pw.println(" * notice, this list of conditions and the following disclaimer."); 124 pw.println(" * 2. Redistributions in binary form must reproduce the above copyright"); 125 pw.println(" * notice, this list of conditions and the following disclaimer in the"); 126 pw.println(" * documentation and/or other materials provided with the distribution."); 127 pw.println(" * 3. The name of the author may not be used to endorse or promote products"); 128 pw.println(" * derived from this software without specific prior written permission."); 129 pw.println(""); 130 pw.println(" * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR"); 131 pw.println(" * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES"); 132 pw.println(" * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED."); 133 pw.println(" * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,"); 134 pw.println(" * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT"); 135 pw.println(" * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,"); 136 pw.println(" * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY"); 137 pw.println(" * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT"); 138 pw.println(" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF"); 139 pw.println(" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."); 140 pw.println(" *"); 141 pw.println(" */"); 142 143 pw.println("package com.hp.hpl.jena.rdf.arp.test;"); 144 pw.println("import junit.framework.TestSuite;"); 145 pw.println("import junit.framework.Test;"); 146 pw.println("import com.hp.hpl.jena.shared.wg.*;"); 147 pw.println("public class TestPackage{"); 148 pw.println("static public Test suite() {"); 149 String tsname = toJava(ts, pw, "xx"); 150 pw.println("return " + tsname+ ";"); 151 pw.println("} }"); 152 pw.println(""); 153 pw.flush(); 154 } 155 156 } | Popular Tags |