1 17 18 package org.apache.tools.ant.taskdefs; 19 20 import org.apache.tools.ant.BuildFileTest; 21 import org.apache.tools.ant.input.PropertyFileInputHandler; 22 import org.apache.tools.ant.util.JavaEnvUtils; 23 24 26 public class InputTest extends BuildFileTest { 27 28 private String targetPostfix = ""; 29 30 public InputTest(String name) { 31 super(name); 32 if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { 33 targetPostfix = ".1"; 34 } 35 } 36 37 public void setUp() { 38 configureProject("src/etc/testcases/taskdefs/input.xml"); 39 System.getProperties() 40 .put(PropertyFileInputHandler.FILE_NAME_KEY, 41 getProject().resolveFile("input.properties") 42 .getAbsolutePath()); 43 getProject().setInputHandler(new PropertyFileInputHandler()); 44 } 45 46 public void test1() { 47 executeTarget("test1" + targetPostfix); 48 } 49 50 public void test2() { 51 executeTarget("test2" + targetPostfix); 52 } 53 54 public void test3() { 55 expectSpecificBuildException("test3" + targetPostfix, "invalid input", 56 "Found invalid input test for \'" 57 + getKey("All data is" 58 + " going to be deleted from DB" 59 + " continue?") 60 + "\'"); 61 } 62 63 public void test5() { 64 executeTarget("test5" + targetPostfix); 65 } 66 67 public void test6() { 68 executeTarget("test6" + targetPostfix); 69 assertEquals("scott", project.getProperty("db.user")); 70 } 71 72 private String getKey(String key) { 73 if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) { 74 key = key.replace(' ', '_'); 75 } 76 return key; 77 } 78 79 } 80 | Popular Tags |