1 17 18 package org.apache.tools.ant.taskdefs.optional; 19 20 import java.io.*; 21 import org.apache.tools.ant.BuildFileTest; 22 23 34 public class ANTLRTest extends BuildFileTest { 35 36 private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/antlr/"; 37 38 public ANTLRTest(String name) { 39 super(name); 40 } 41 42 public void setUp() { 43 configureProject(TASKDEFS_DIR + "antlr.xml"); 44 } 45 46 public void tearDown() { 47 executeTarget("cleanup"); 48 } 49 50 public void test1() { 51 expectBuildException("test1", "required argument, target, missing"); 52 } 53 54 public void test2() { 55 expectBuildException("test2", "Invalid output directory"); 56 } 57 58 public void test3() { 59 executeTarget("test3"); 60 File outputDirectory = new File(TASKDEFS_DIR + "antlr.tmp"); 61 String [] calcFiles = outputDirectory.list(new CalcFileFilter()); 62 assertEquals(5, calcFiles.length); 63 } 64 65 public void test4() { 66 executeTarget("test4"); 67 } 68 69 public void test5() { 70 expectBuildException("test5", "ANTLR returned: 1"); 73 } 74 75 public void test6() { 76 executeTarget("test6"); 77 } 78 79 public void test7() { 80 expectBuildException("test7", "Unable to determine generated class"); 81 } 82 83 86 public void test8() { 87 expectBuildException("test8", "Invalid super grammar file"); 88 } 89 90 94 public void test9() { 95 executeTarget("test9"); 96 } 97 98 102 public void test10() { 103 executeTarget("test10"); 104 File outputDirectory = new File(TASKDEFS_DIR + "antlr.tmp"); 105 String [] calcFiles = outputDirectory.list(new HTMLFilter()); 106 assertTrue(calcFiles.length > 0); 107 } 108 109 113 public void test11() { 114 executeTarget("test11"); 115 } 116 117 121 public void test12() { 122 executeTarget("test12"); 123 } 124 125 130 public void test13() { 131 executeTarget("test13"); 132 } 133 134 public void testNoRecompile() { 135 executeTarget("test9"); 136 assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); 137 executeTarget("noRecompile"); 138 assertTrue(-1 != getFullLog().indexOf("Skipped grammar file.")); 139 } 140 141 public void testNormalRecompile() { 142 executeTarget("test9"); 143 assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); 144 executeTarget("normalRecompile"); 145 assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); 146 } 147 148 public void testSupergrammarChangeRecompile() { 150 executeTarget("test9"); 151 assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); 152 executeTarget("supergrammarChangeRecompile"); 153 assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); 154 } 155 } 156 157 class CalcFileFilter implements FilenameFilter { 158 public boolean accept(File dir, String name) { 159 return name.startsWith("Calc"); 160 } 161 } 162 163 class HTMLFilter implements FilenameFilter { 164 public boolean accept(File dir, String name) { 165 return name.endsWith("html"); 166 } 167 } 168 | Popular Tags |