bodewig 02/04/23 03:29:42
Modified: src/testcases/org/apache/tools/ant/taskdefs InputTest.java
src/etc/testcases/taskdefs input.properties input.xml
src/main/org/apache/tools/ant/input
PropertyFileInputHandler.java
Log:
JDK 1.1 doesn't seem to grok spaces in the keys of a properties file,
no matter which version of escapes I have tried.
Revision Changes Path
1.4 +26 -10 jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/InputTest.java
Index: InputTest.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/InputTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InputTest.java 22 Apr 2002 11:55:21 -0000 1.3
+++ InputTest.java 23 Apr 2002 10:29:42 -0000 1.4
@@ -56,6 +56,7 @@
import org.apache.tools.ant.BuildFileTest;
import org.apache.tools.ant.input.PropertyFileInputHandler;
+import org.apache.tools.ant.util.JavaEnvUtils;
/**
* @author Ulrich Schmidt <usch@usch.net>
@@ -63,40 +64,55 @@
*/
public class InputTest extends BuildFileTest {
+ private String targetPostfix = "";
+
public InputTest(String name) {
super(name);
+ if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
+ targetPostfix = ".1";
+ }
}
public void setUp() {
+ configureProject("src/etc/testcases/taskdefs/input.xml");
System.getProperties()
.put(PropertyFileInputHandler.FILE_NAME_KEY,
- "src/etc/testcases/taskdefs/input.properties");
- configureProject("src/etc/testcases/taskdefs/input.xml");
+ getProject().resolveFile("input.properties")
+ .getAbsolutePath());
getProject().setInputHandler(new PropertyFileInputHandler());
}
public void test1() {
- executeTarget("test1");
+ executeTarget("test1" + targetPostfix);
}
public void test2() {
- executeTarget("test1");
+ executeTarget("test2" + targetPostfix);
}
public void test3() {
- expectSpecificBuildException("test3", "invalid input",
- "Found invalid input test for All data is"
- + " going to be deleted from DB"
- + " continue?");
+ expectSpecificBuildException("test3" + targetPostfix, "invalid input",
+ "Found invalid input test for \'"
+ + getKey("All data is"
+ + " going to be deleted from DB"
+ + " continue?")
+ + "\'");
}
public void test5() {
- executeTarget("test5");
+ executeTarget("test5" + targetPostfix);
}
public void test6() {
- executeTarget("test6");
+ executeTarget("test6" + targetPostfix);
assertEquals("scott", project.getProperty("db.user"));
+ }
+
+ private String getKey(String key) {
+ if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1)) {
+ key = key.replace(' ', '_');
+ }
+ return key;
}
}
1.2 +7 -0 jakarta-ant/src/etc/testcases/taskdefs/input.properties
Index: input.properties
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/input.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- input.properties 22 Apr 2002 11:55:21 -0000 1.1
+++ input.properties 23 Apr 2002 10:29:42 -0000 1.2
@@ -2,3 +2,10 @@
All\ data\ is\ going\ to\ be\ deleted\ from\ DB\ continue?=test
All\ data\ is\ going\ to\ be\ deleted\ from\ db\ continue\ (y/n)?=y
Please\ enter\ db-username\:=scott
+#
+# JDK 1.1 doesn't seem to handle blanks in the property key
+#
+Press_Return_key_to_continue...=test
+All_data_is_going_to_be_deleted_from_DB_continue?=test
+All_data_is_going_to_be_deleted_from_db_continue_(y/n)?=y
+Please_enter_db_username=scott
1.4 +26 -0 jakarta-ant/src/etc/testcases/taskdefs/input.xml
Index: input.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/input.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- input.xml 22 Apr 2002 11:55:21 -0000 1.3
+++ input.xml 23 Apr 2002 10:29:42 -0000 1.4
@@ -28,4 +28,30 @@
/>
</target>
+ <target name="test1.1">
+ <input>Press_Return_key_to_continue...</input>
+ </target>
+
+ <target name="test2.1">
+ <input message="Press_Return_key_to_continue..." />
+ </target>
+
+ <target name="test3.1">
+ <input message="All_data_is_going_to_be_deleted_from_DB_continue?"
+ validargs="y,n"
+ />
+ </target>
+
+ <target name="test5.1">
+ <input message="All_data_is_going_to_be_deleted_from_db_continue_(y/n)?"
+ validargs="y,n"
+ />
+ </target>
+
+ <target name="test6.1">
+ <input message="Please_enter_db_username"
+ addproperty="db.user"
+ />
+ </target>
+
</project>
1.2 +5 -4 jakarta-ant/src/main/org/apache/tools/ant/input/PropertyFileInputHandler.java
Index: PropertyFileInputHandler.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/input/PropertyFileInputHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PropertyFileInputHandler.java 22 Apr 2002 11:55:21 -0000 1.1
+++ PropertyFileInputHandler.java 23 Apr 2002 10:29:42 -0000 1.2
@@ -65,7 +65,7 @@
* system property ant.input.properties, the prompt is the key for input.
*
* @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
* @since Ant 1.5
*/
public class PropertyFileInputHandler implements InputHandler {
@@ -90,15 +90,16 @@
*/
public void handleInput(InputRequest request) throws BuildException {
readProps();
+
Object o = props.get(request.getPrompt());
if (o == null) {
- throw new BuildException("Unable to find input for "
- + request.getPrompt());
+ throw new BuildException("Unable to find input for \'"
+ + request.getPrompt()+"\'");
}
request.setInput(o.toString());
if (!request.isInputValid()) {
throw new BuildException("Found invalid input " + o
- + " for " + request.getPrompt());
+ + " for \'" + request.getPrompt() + "\'");
}
}
--
To unsubscribe, e-mail: <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
|