1 17 package org.apache.tools.ant.taskdefs; 18 19 import org.apache.tools.ant.BuildFileTest; 20 import org.apache.tools.ant.Project; 21 import org.apache.tools.ant.BuildException; 22 import java.io.File ; 23 24 29 public class LoadFileTest extends BuildFileTest { 30 31 36 public LoadFileTest(String name) { 37 super(name); 38 } 39 40 41 44 public void setUp() { 45 configureProject("src/etc/testcases/taskdefs/loadfile.xml"); 46 } 47 48 49 52 public void tearDown() { 53 executeTarget("cleanup"); 54 } 55 56 57 60 public void testNoSourcefileDefined() { 61 expectBuildException("testNoSourcefileDefined", 62 "source file not defined"); 63 } 64 65 66 69 public void testNoPropertyDefined() { 70 expectBuildException("testNoPropertyDefined", 71 "output property not defined"); 72 } 73 74 75 78 public void testNoSourcefilefound() { 79 expectBuildExceptionContaining("testNoSourcefilefound", 80 "File not found", 81 "Unable to load file"); 82 } 83 84 87 public void testFailOnError() 88 throws BuildException { 89 expectPropertyUnset("testFailOnError","testFailOnError"); 90 } 91 92 93 96 public void testLoadAFile() 97 throws BuildException { 98 executeTarget("testLoadAFile"); 99 if(project.getProperty("testLoadAFile").indexOf("eh?")<0) { 100 fail("property is not all in the file"); 101 } 102 } 103 104 105 108 public void testLoadAFileEnc() 109 throws BuildException { 110 executeTarget("testLoadAFileEnc"); 111 if(project.getProperty("testLoadAFileEnc")==null) { 112 fail("file load failed"); 113 } 114 } 115 116 119 public void testEvalProps() 120 throws BuildException { 121 executeTarget("testEvalProps"); 122 if(project.getProperty("testEvalProps").indexOf("rain")<0) { 123 fail("property eval broken"); 124 } 125 } 126 127 130 public void testFilterChain() 131 throws BuildException { 132 executeTarget("testFilterChain"); 133 if(project.getProperty("testFilterChain").indexOf("World!")<0) { 134 fail("Filter Chain broken"); 135 } 136 } 137 138 141 public final void testStripJavaComments() 142 throws BuildException { 143 executeTarget("testStripJavaComments"); 144 final String expected = project.getProperty("expected"); 145 final String generated = project.getProperty("testStripJavaComments"); 146 assertEquals(expected, generated); 147 } 148 149 152 public void testOneLine() 153 throws BuildException { 154 expectPropertySet("testOneLine","testOneLine","1,2,3,4"); 155 156 } 157 } 158 | Popular Tags |