01 /*
02 * TreeTranslatorTests.java
03 * Copyright (c) 1998-2008, The University of Sheffield.
04 *
05 * This code is from the GATE project (http://gate.ac.uk/) and is free
06 * software licenced under the GNU General Public License version 3. It is
07 * distributed without any warranty. For more details see COPYING.txt in the
08 * top level directory (or at http://gatewiki.sf.net/COPYING.txt).
09 *
10 * Hamish Cunningham, 3rd May 2006
11 */
12
13 package gate.yam.translate;
14
15 import java.io.*;
16 import junit.framework.*;
17 import gate.util.*;
18 import gate.yam.*;
19
20
21 /**
22 * Unit test for TreeTranslator.
23 */
24 public class TreeTranslatorTests extends AbstractTranslatorTest
25 {
26 /** Create the test case. */
27 public TreeTranslatorTests(String testName) { super(testName); }
28
29 /** Paths of example test files. */
30 public String[] getTestFilePaths() {
31 String testFilePaths[] = {
32 // "/yam-comprehensive",
33 "/yam-pretty",
34 "/yam-scratch",
35 "/yam-lists",
36 "/yam-small-error",
37 "/yam-errors",
38 "/yam-minimal",
39 "/yam-urls",
40 "/yam-first"
41 };
42 return testFilePaths;
43 }
44
45 /** Suffix of input files. */
46 public String getInputSuffix() { return "yam"; }
47
48 /** Suffix of output files. */
49 public String[] getOutputSuffixes() {
50 String outputSuffixes[] = {
51 "tree"
52 };
53 return outputSuffixes;
54 }
55
56 /** Run the translator and get the response */
57 public Writer doTranslation(
58 Reader testReader, Writer responseWriter, String outputType,
59 String testName
60 ) throws Exception {
61 // find the source directory
62 String testFilePath =
63 this.getClass().getResource(testName + ".yam").getPath();
64 File testFileDir = new File(testFilePath).getParentFile();
65
66 if(outputType.equals("tree")) {
67 YamCommand yam = new YamCommand();
68 yam.translate(
69 testReader, responseWriter, YamFile.FileType.TREE, testFileDir
70 );
71 } else {
72 throw new GateException("unknown output type " + outputType);
73 }
74 return responseWriter;
75 }
76 }
|