diff --git a/src/main/org/apache/tools/ant/TaskAdapter.java b/src/main/org/apache/tools/ant/TaskAdapter.java index 23f97a4d2..273fa0689 100644 --- a/src/main/org/apache/tools/ant/TaskAdapter.java +++ b/src/main/org/apache/tools/ant/TaskAdapter.java @@ -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 @@ public class TaskAdapter extends Task { } 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 ); diff --git a/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java b/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java index 9296e88bc..0d8e49687 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/ConditionTask.java @@ -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 @@ -73,7 +73,7 @@ import org.apache.tools.ant.taskdefs.condition.ConditionBase; */ public class ConditionTask extends ConditionBase { - private String property; + private String property = null; private String value = "true"; /** @@ -102,6 +102,10 @@ public class ConditionTask extends ConditionBase { if (countConditions() < 1) { throw new BuildException("You must nest a condition into "); } + if (property == null) { + throw new BuildException("The property attribute is required."); + } + Condition c = (Condition) getConditions().nextElement(); if (c.eval()) { getProject().setNewProperty(property, value); diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java index 58b28222f..89aa9037f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java @@ -110,7 +110,7 @@ public class FilesMatch implements Condition { //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 diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java index a6bfd5141..11061830f 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java @@ -93,24 +93,16 @@ public class ConditionTest extends BuildFileTest { 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 "); } public void testShortcut() { @@ -133,14 +125,10 @@ public class ConditionTest extends BuildFileTest { expectPropertyUnset("negationfalse","negationfalse"); } - /** - * @todo have this reject the current error - */ public void testNegationIncomplete() { - try { - executeTarget("negationincomplete"); - } catch(Exception e) { - } + expectSpecificBuildException("negationincomplete", + "no conditions in ", + "You must nest a condition into "); } public void testAnd() { @@ -180,33 +168,20 @@ public class ConditionTest extends BuildFileTest { } - /** - * @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"); }