bodewig 02/02/19 08:17:25
Modified: src/main/org/apache/tools/ant TaskAdapter.java
src/main/org/apache/tools/ant/taskdefs ConditionTask.java
src/main/org/apache/tools/ant/taskdefs/condition
FilesMatch.java
src/testcases/org/apache/tools/ant/taskdefs
ConditionTest.java
Log:
Better handling of tasks that are wrapped in TaskAdapters - unwrap
InvocationTargetExceptions when they happen
PR: 5830
To test it I've enabled all tests for <condition>.
Revision Changes Path
1.13 +9 -1
jakarta-ant/src/main/org/apache/tools/ant/TaskAdapter.java
Index: TaskAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/TaskAdapter.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TaskAdapter.java 20 Jan 2002 20:45:56 -0000 1.12
+++ TaskAdapter.java 19 Feb 2002 16:17:25 -0000 1.13
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -131,6 +131,14 @@
}
executeM.invoke(proxy, null);
return;
+ } catch (java.lang.reflect.InvocationTargetException ie) {
+ log("Error in " + proxy.getClass(), Project.MSG_ERR);
+ Throwable t = ie.getTargetException();
+ if (t instanceof BuildException) {
+ throw ((BuildException) t);
+ } else {
+ throw new BuildException(t);
+ }
} catch( Exception ex ) {
log("Error in " + proxy.getClass(), Project.MSG_ERR);
throw new BuildException( ex );
1.4 +7 -3
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java
Index: ConditionTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ConditionTask.java 30 Nov 2001 17:35:06 -0000 1.3
+++ ConditionTask.java 19 Feb 2002 16:17:25 -0000 1.4
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -69,11 +69,11 @@
* ConditionBase.</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class ConditionTask extends ConditionBase {
- private String property;
+ private String property = null;
private String value = "true";
/**
@@ -102,6 +102,10 @@
if (countConditions() < 1) {
throw new BuildException("You must nest a condition into
<condition>");
}
+ if (property == null) {
+ throw new BuildException("The property attribute is required.");
+ }
+
Condition c = (Condition) getConditions().nextElement();
if (c.eval()) {
getProject().setNewProperty(property, value);
1.4 +2 -2
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
Index: FilesMatch.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FilesMatch.java 1 Feb 2002 07:24:40 -0000 1.3
+++ FilesMatch.java 19 Feb 2002 16:17:25 -0000 1.4
@@ -63,7 +63,7 @@
* are not looked at at all.
*
* @author Steve Loughran
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
* @created 12 January 2002
* @since Ant 1.5
*/
@@ -110,7 +110,7 @@
//validate
if (file1 == null || file2 == null) {
- throw new BuildException("both file1 and file2 are required in
fileequals");
+ throw new BuildException("both file1 and file2 are required in
filesmatch");
}
//#now match the files
1.3 +14 -39
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java
Index: ConditionTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ConditionTest.java 16 Jan 2002 11:25:49 -0000 1.2
+++ ConditionTest.java 19 Feb 2002 16:17:25 -0000 1.3
@@ -93,24 +93,16 @@
expectPropertySet("basic","basic");
}
- /**
- * @todo have this reject the current error
- */
public void testConditionIncomplete() {
- try {
- executeTarget("condition-incomplete");
- } catch(Exception e) {
- }
+ expectSpecificBuildException("condition-incomplete",
+ "property attribute has been omitted",
+ "The property attribute is required.");
}
- /**
- * @todo have this reject the current error
- */
public void testConditionEmpty() {
- try {
- executeTarget("condition-empty");
- } catch(Exception e) {
- }
+ expectSpecificBuildException("condition-empty",
+ "no conditions",
+ "You must nest a condition into
<condition>");
}
public void testShortcut() {
@@ -133,14 +125,10 @@
expectPropertyUnset("negationfalse","negationfalse");
}
- /**
- * @todo have this reject the current error
- */
public void testNegationIncomplete() {
- try {
- executeTarget("negationincomplete");
- } catch(Exception e) {
- }
+ expectSpecificBuildException("negationincomplete",
+ "no conditions in <not>",
+ "You must nest a condition into
<not>");
}
public void testAnd() {
@@ -180,33 +168,20 @@
}
- /**
- * @todo have this reject the current error
- */
public void testFilesmatchIncomplete() {
- try {
- executeTarget("filesmatch-incomplete");
- } catch(Exception e) {
- }
- }
+ expectSpecificBuildException("filesmatch-incomplete",
+ "Missing file2 attribute",
+ "both file1 and file2 are required in
filesmatch");
+ }
public void testFilesmatchOddsizes() {
expectPropertyUnset("filesmatch-oddsizes","filesmatch-oddsizes");
}
- /**
- * @todo have this reject the current error
- */
public void testFilesmatchExistence() {
- try {
- executeTarget("filesmatch-existence");
- } catch(Exception e) {
- }
+ expectPropertyUnset("filesmatch-existence", "filesmatch-existence");
}
- /**
- * @todo have this reject the current error
- */
public void testFilesmatchDifferent() {
expectPropertyUnset("filesmatch-different","filesmatch-different");
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>