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.xml.TestRepositioningInfo;
47
48 import gnu.getopt.Getopt;
49
50
73
74 public class TestGate {
75
76
77 private static final boolean DEBUG = false;
78
79
80 private static final int STATUS_NORMAL = 0;
81
82
83 private static final int STATUS_ERROR = 1;
84
85 private static final String
86 defOracleDriver = "jdbc:oracle:thin:@derwent:1521:dbgate";
87 private static final String
88 saiOracleDriver = "jdbc:oracle:thin:GATEUSER/gate@192.168.128.7:1521:GATE04";
89 private static final String
90 defPSQLDriver = "jdbc:postgresql://redmires/gate";
91 private static final String
92 saiPSQLDriver = "jdbc:postgresql://sirma/gate";
93
94
95 public static String oracleDriver = defOracleDriver;
96 public static String psqlDriver = defPSQLDriver;
97
98
116 public static void main(String[] args) throws Exception {
117 boolean textMode = false;
118 boolean autoloadingMode = false;
119
120 Getopt g = new Getopt("GATE test suite", args, "tnNasi:");
122 int c;
123 while( (c = g.getopt()) != -1 )
124 switch(c) {
125 case 't':
126 textMode = true;
127 break;
128 case 'n':
129 Gate.setNetConnected(false);
130 break;
131 case 'N':
132 Gate.setNetConnected(false);
133 Gate.setLocalWebServer(false);
134 break;
135 case 'a':
136 autoloadingMode = true;
137 break;
138 case 's':
139 oracleDriver = saiOracleDriver;
140 psqlDriver = saiPSQLDriver;
141 break;
142 case 'i':
144 String optionString = g.getOptarg();
145 URL u = null;
146 File f = new File(optionString);
147 try {
148 u = f.toURL();
149 } catch(MalformedURLException e) {
150 Err.prln("Bad initialisation file: " + optionString);
151 Err.prln(e);
152 System.exit(STATUS_ERROR);
153 }
154 Gate.setSiteConfigFile(f);
155 Out.prln(
156 "Initialisation file " + optionString +
157 " recorded for initialisation"
158 );
159 break;
160 case '?':
161 return;
163 default:
164 Err.prln("getopt() returned " + c + "\n");
165 }
167 String junitArgs[] = new String[2];
169 junitArgs[0] = "-noloading";
170 junitArgs[1] = "gate.TestGate";
171
172
175 if(textMode) { junit.textui.TestRunner.main(junitArgs);
178 } else if(autoloadingMode) { junitArgs[0] = "gate.TestGate";
180 junitArgs[1] = "";
181
182 Class clazz = null;
185 clazz = Class.forName("oracle.jdbc.driver.OracleDriver");
186 clazz = null;
187 junit.swingui.TestRunner.main(junitArgs);
188
189 } else { junit.swingui.TestRunner.main(junitArgs);
191 }
192
193 }
195
198 public static Test suite() throws Exception {
199
204 try {
205 String configFile = System.getProperty("gate.config");
207 if(configFile != null && configFile.length() > 0){
208 File f = new File(configFile);
209 try {
210 URL u = f.toURL();
211 } catch(MalformedURLException e) {
212 Err.prln("Bad initialisation file: " + configFile);
213 Err.prln(e);
214 System.exit(STATUS_ERROR);
215 }
216 Gate.setSiteConfigFile(f);
217 }
218 Gate.init();
219 } catch(GateException e) {
220 Out.prln("can't initialise GATE library! exception = " + e);
221 throw(e);
222 }
223
224 TestSuite suite = new TestSuite();
225
226 try {
227 boolean allTests = true;
232 if(! allTests){
233 suite.addTest(TestPR.suite());
234 } else {
235
236 suite.addTest(TestWordNet.suite());
237 suite.addTest(TestIndex.suite());
238 suite.addTest(TestPersist.suite());
239 suite.addTest(TestBumpyStack.suite());
240 suite.addTest(TestControllers.suite());
241 suite.addTest(TestSecurity.suite());
242 suite.addTest(TestAnnotationDiff.suite());
243 suite.addTest(TestConfig.suite());
244 suite.addTest(TestAnnotation.suite());
245 suite.addTest(TestEmail.suite());
246
247 suite.addTest(TestXml.suite());
248 suite.addTest(TestHtml.suite());
249 suite.addTest(TestSgml.suite());
250 suite.addTest(TestXSchema.suite());
251
252 suite.addTest(TestCreole.suite());
253 suite.addTest(CookBook.suite());
254 suite.addTest(TestFiles.suite());
255 suite.addTest(TestJavac.suite());
256 suite.addTest(TestReload.suite());
257 suite.addTest(TestJape.suite());
258 suite.addTest(TestTemplate.suite());
259
262 suite.addTest(TestDocument.suite());
264 suite.addTest(TestRBTreeMap.suite());
265 suite.addTest(TestCorpus.suite());
266 suite.addTest(TestSerialCorpus.suite());
267 suite.addTest(TestDiffer.suite());
268 suite.addTest(TestFeatureMap.suite());
273 suite.addTest(TestPR.suite());
274 suite.addTest(TestMorph.suite());
275 suite.addTest(TestMaxentWrapper.suite());
276
277 suite.addTest(TestHashGazetteer.suite());
279 suite.addTest(TestRepositioningInfo.suite());
280 suite.addTest(TestFlexibleGazetteer.suite());
281
282 }
284 } catch(Exception e) {
285 Out.prln("can't add tests! exception = " + e);
286 throw(e);
287 }
288
289 return suite;
290 }
292 }