1
15
16 package gate;
17
18 import java.io.File;
19 import java.net.MalformedURLException;
20 import java.net.URL;
21 import java.util.StringTokenizer;
22
23 import junit.framework.Test;
24 import junit.framework.TestSuite;
25
26 import com.ontotext.gate.gazetteer.TestHashGazetteer;
27
28 import gate.annotation.TestAnnotation;
29 import gate.annotation.TestAnnotationDiff;
30 import gate.config.TestConfig;
31 import gate.corpora.*;
32 import gate.creole.*;
33 import gate.creole.ir.TestIndex;
34 import gate.creole.morph.TestMorph;
35 import gate.creole.gazetteer.TestFlexibleGazetteer;
36 import gate.email.TestEmail;
37 import gate.html.TestHtml;
38 import gate.jape.TestJape;
39 import gate.persist.TestPersist;
40 import gate.security.TestSecurity;
41 import gate.sgml.TestSgml;
42 import gate.util.*;
43 import gate.wordnet.TestWordNet;
44 import gate.xml.TestXml;
45 import gate.creole.ml.maxent.*;
46 import gate.creole.ontology.TestOntologyAPI;
47 import gate.xml.TestRepositioningInfo;
48
49 import gnu.getopt.Getopt;
50
51
74
75 public class TestGate {
76
77
78 private static final boolean DEBUG = false;
79
80
81 private static final int STATUS_NORMAL = 0;
82
83
84 private static final int STATUS_ERROR = 1;
85
86 private static final String
87 defOracleDriver = "jdbc:oracle:thin:@derwent:1521:dbgate";
88 private static final String
89 saiOracleDriver = "jdbc:oracle:thin:GATEUSER/gate@192.168.128.7:1521:GATE04";
90 private static final String
91 defPSQLDriver = "jdbc:postgresql://redmires/gate";
92 private static final String
93 saiPSQLDriver = "jdbc:postgresql://sirma/gate";
94
95
96 public static String oracleDriver = defOracleDriver;
97 public static String psqlDriver = defPSQLDriver;
98
99
117 public static void main(String[] args) throws Exception {
118 boolean textMode = false;
119 boolean autoloadingMode = false;
120
121 Getopt g = new Getopt("GATE test suite", args, "tnNasi:");
123 int c;
124 while( (c = g.getopt()) != -1 )
125 switch(c) {
126 case 't':
127 textMode = true;
128 break;
129 case 'n':
130 Gate.setNetConnected(false);
131 break;
132 case 'N':
133 Gate.setNetConnected(false);
134 Gate.setLocalWebServer(false);
135 break;
136 case 'a':
137 autoloadingMode = true;
138 break;
139 case 's':
140 oracleDriver = saiOracleDriver;
141 psqlDriver = saiPSQLDriver;
142 break;
143 case 'i':
145 String optionString = g.getOptarg();
146 URL u = null;
147 File f = new File(optionString);
148 try {
149 u = f.toURL();
150 } catch(MalformedURLException e) {
151 Err.prln("Bad initialisation file: " + optionString);
152 Err.prln(e);
153 System.exit(STATUS_ERROR);
154 }
155 Gate.setSiteConfigFile(f);
156 Out.prln(
157 "Initialisation file " + optionString +
158 " recorded for initialisation"
159 );
160 break;
161 case '?':
162 return;
164 default:
165 Err.prln("getopt() returned " + c + "\n");
166 }
168 String junitArgs[] = new String[2];
170 junitArgs[0] = "-noloading";
171 junitArgs[1] = "gate.TestGate";
172
173
176 if(textMode) { junit.textui.TestRunner.main(junitArgs);
179 } else if(autoloadingMode) { junitArgs[0] = "gate.TestGate";
181 junitArgs[1] = "";
182
183 Class clazz = null;
186 clazz = Class.forName("oracle.jdbc.driver.OracleDriver");
187 clazz = null;
188 junit.swingui.TestRunner.main(junitArgs);
189
190 } else { junit.swingui.TestRunner.main(junitArgs);
192 }
193
194 }
196
199 public static Test suite() throws Exception {
200
205 try {
206 String configFile = System.getProperty("gate.config");
208 if(configFile != null && configFile.length() > 0){
209 File f = new File(configFile);
210 try {
211 URL u = f.toURL();
212 } catch(MalformedURLException e) {
213 Err.prln("Bad initialisation file: " + configFile);
214 Err.prln(e);
215 System.exit(STATUS_ERROR);
216 }
217 Gate.setSiteConfigFile(f);
218 }
219 Gate.init();
220 } catch(GateException e) {
221 Out.prln("can't initialise GATE library! exception = " + e);
222 throw(e);
223 }
224
225 TestSuite suite = new TestSuite();
226
227 try {
228 boolean allTests = true;
233 if(! allTests){
234 suite.addTest(TestPR.suite());
235 } else {
236
237 suite.addTest(TestWordNet.suite());
238 suite.addTest(TestIndex.suite());
239 suite.addTest(TestPersist.suite());
240 suite.addTest(TestBumpyStack.suite());
241 suite.addTest(TestControllers.suite());
242 suite.addTest(TestSecurity.suite());
243 suite.addTest(TestAnnotationDiff.suite());
244 suite.addTest(TestConfig.suite());
245 suite.addTest(TestAnnotation.suite());
246 suite.addTest(TestEmail.suite());
247 suite.addTest(TestOntologyAPI.suite());
248
249 suite.addTest(TestXml.suite());
250 suite.addTest(TestHtml.suite());
251 suite.addTest(TestSgml.suite());
252 suite.addTest(TestXSchema.suite());
253
254 suite.addTest(TestCreole.suite());
255 suite.addTest(CookBook.suite());
256 suite.addTest(TestFiles.suite());
257 suite.addTest(TestJavac.suite());
258 suite.addTest(TestReload.suite());
259 suite.addTest(TestJape.suite());
260 suite.addTest(TestTemplate.suite());
261
264 suite.addTest(TestDocument.suite());
266 suite.addTest(TestRBTreeMap.suite());
267 suite.addTest(TestCorpus.suite());
268 suite.addTest(TestSerialCorpus.suite());
269 suite.addTest(TestDiffer.suite());
270 suite.addTest(TestFeatureMap.suite());
275 suite.addTest(TestPR.suite());
276 suite.addTest(TestMorph.suite());
277 suite.addTest(TestMaxentWrapper.suite());
278
279 suite.addTest(TestHashGazetteer.suite());
281 suite.addTest(TestRepositioningInfo.suite());
282 suite.addTest(TestFlexibleGazetteer.suite());
283
284 }
286 } catch(Exception e) {
287 Out.prln("can't add tests! exception = " + e);
288 throw(e);
289 }
290
291 return suite;
292 }
294 }