diff --git a/proposal/myrmidon/etc/testcases/org/apache/antlib/core/if.ant b/proposal/myrmidon/etc/testcases/org/apache/antlib/core/if.ant
new file mode 100644
index 000000000..b3caca2af
--- /dev/null
+++ b/proposal/myrmidon/etc/testcases/org/apache/antlib/core/if.ant
@@ -0,0 +1,63 @@
+
+
+
+
+ test-prop is set
+
+
+ test-prop is not set
+
+
+
+
+
+
+ test-prop is set
+
+
+ test-prop is not set
+
+
+
+
+
+ test-prop is set
+
+
+ test-prop is not set
+
+
+
+
+
+
+ test-prop is set
+
+
+ test-prop is not set
+
+
+
+
+
+
+ task 1
+ task 2
+ task 3
+ task 4
+
+
+
+
+
+ no go
+
+
+
+
+
+ no go
+
+
+
+
\ No newline at end of file
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java b/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
index d6272638d..9472a0cf9 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
+++ b/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
@@ -74,9 +74,16 @@ public class IfTask
throw new TaskException( message );
}
+ // Evaluate the condition
+ if( ! m_condition.evaluate( getContext() ) )
+ {
+ return;
+ }
+
final Configuration[] tasks =
(Configuration[])m_tasks.toArray( new Configuration[ m_tasks.size() ] );
+ // TODO - don't use getService()
final ExecutionFrame frame = (ExecutionFrame)getService( ExecutionFrame.class );
final Executor executor = (Executor)getService( Executor.class );
diff --git a/proposal/myrmidon/src/test/org/apache/antlib/core/IfTest.java b/proposal/myrmidon/src/test/org/apache/antlib/core/IfTest.java
new file mode 100644
index 000000000..c4022d2e2
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/antlib/core/IfTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.antlib.core;
+
+import java.io.File;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.myrmidon.AbstractProjectTest;
+import org.apache.myrmidon.LogMessageTracker;
+
+/**
+ * Test cases for the task.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+public class IfTest
+ extends AbstractProjectTest
+{
+ private final static Resources REZ
+ = ResourceManager.getPackageResources( IfTest.class );
+
+ public IfTest( String name )
+ {
+ super( name );
+ }
+
+ /**
+ * Test checking whether a property is set and not 'false'.
+ */
+ public void testConditions()
+ throws Exception
+ {
+ final File projectFile = getTestResource( "if.ant" );
+
+ // Test when property is set to 'true'
+ LogMessageTracker listener = new LogMessageTracker();
+ listener.addExpectedMessage( "true-prop", "test-prop is set" );
+ executeTarget( projectFile, "true-prop", listener );
+
+ // Test when property is set to a value other than 'true' or 'false'
+ listener = new LogMessageTracker();
+ listener.addExpectedMessage( "set-prop", "test-prop is set" );
+ executeTarget( projectFile, "set-prop", listener );
+
+ // Test when property is set to 'false'
+ listener = new LogMessageTracker();
+ listener.addExpectedMessage( "false-prop", "test-prop is not set" );
+ executeTarget( projectFile, "false-prop", listener );
+
+ // Test when property is not set
+ listener = new LogMessageTracker();
+ listener.addExpectedMessage( "not-set-prop", "test-prop is not set" );
+ executeTarget( projectFile, "not-set-prop", listener );
+ }
+
+ /**
+ * Tests that the task can handle multiple nested tasks.
+ */
+ public void testMultipleTasks() throws Exception
+ {
+ final File projectFile = getTestResource( "if.ant" );
+
+ // Test when property is not set
+ LogMessageTracker listener = new LogMessageTracker();
+ listener.addExpectedMessage( "multiple-nested-tasks", "task 1" );
+ listener.addExpectedMessage( "multiple-nested-tasks", "task 2" );
+ listener.addExpectedMessage( "multiple-nested-tasks", "task 3" );
+ listener.addExpectedMessage( "multiple-nested-tasks", "task 4" );
+ executeTarget( projectFile, "multiple-nested-tasks", listener );
+ }
+
+ /**
+ * Tests validation.
+ */
+ public void testValidation() throws Exception
+ {
+ final File projectFile = getTestResource( "if.ant" );
+
+ // Check for missing condition
+ String message = REZ.getString( "if.no-condition.error" );
+ executeTargetExpectError( projectFile, "no-condition", message );
+
+ // Check for too many conditions
+ String[] messages =
+ {
+ null,
+ null,
+ REZ.getString( "if.ifelse-duplicate.error" )
+ };
+ executeTargetExpectError( projectFile, "too-many-conditions", messages );
+ }
+
+}
diff --git a/proposal/myrmidon/src/testcases/org/apache/antlib/core/IfTest.java b/proposal/myrmidon/src/testcases/org/apache/antlib/core/IfTest.java
new file mode 100644
index 000000000..c4022d2e2
--- /dev/null
+++ b/proposal/myrmidon/src/testcases/org/apache/antlib/core/IfTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.antlib.core;
+
+import java.io.File;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.myrmidon.AbstractProjectTest;
+import org.apache.myrmidon.LogMessageTracker;
+
+/**
+ * Test cases for the task.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+public class IfTest
+ extends AbstractProjectTest
+{
+ private final static Resources REZ
+ = ResourceManager.getPackageResources( IfTest.class );
+
+ public IfTest( String name )
+ {
+ super( name );
+ }
+
+ /**
+ * Test checking whether a property is set and not 'false'.
+ */
+ public void testConditions()
+ throws Exception
+ {
+ final File projectFile = getTestResource( "if.ant" );
+
+ // Test when property is set to 'true'
+ LogMessageTracker listener = new LogMessageTracker();
+ listener.addExpectedMessage( "true-prop", "test-prop is set" );
+ executeTarget( projectFile, "true-prop", listener );
+
+ // Test when property is set to a value other than 'true' or 'false'
+ listener = new LogMessageTracker();
+ listener.addExpectedMessage( "set-prop", "test-prop is set" );
+ executeTarget( projectFile, "set-prop", listener );
+
+ // Test when property is set to 'false'
+ listener = new LogMessageTracker();
+ listener.addExpectedMessage( "false-prop", "test-prop is not set" );
+ executeTarget( projectFile, "false-prop", listener );
+
+ // Test when property is not set
+ listener = new LogMessageTracker();
+ listener.addExpectedMessage( "not-set-prop", "test-prop is not set" );
+ executeTarget( projectFile, "not-set-prop", listener );
+ }
+
+ /**
+ * Tests that the task can handle multiple nested tasks.
+ */
+ public void testMultipleTasks() throws Exception
+ {
+ final File projectFile = getTestResource( "if.ant" );
+
+ // Test when property is not set
+ LogMessageTracker listener = new LogMessageTracker();
+ listener.addExpectedMessage( "multiple-nested-tasks", "task 1" );
+ listener.addExpectedMessage( "multiple-nested-tasks", "task 2" );
+ listener.addExpectedMessage( "multiple-nested-tasks", "task 3" );
+ listener.addExpectedMessage( "multiple-nested-tasks", "task 4" );
+ executeTarget( projectFile, "multiple-nested-tasks", listener );
+ }
+
+ /**
+ * Tests validation.
+ */
+ public void testValidation() throws Exception
+ {
+ final File projectFile = getTestResource( "if.ant" );
+
+ // Check for missing condition
+ String message = REZ.getString( "if.no-condition.error" );
+ executeTargetExpectError( projectFile, "no-condition", message );
+
+ // Check for too many conditions
+ String[] messages =
+ {
+ null,
+ null,
+ REZ.getString( "if.ifelse-duplicate.error" )
+ };
+ executeTargetExpectError( projectFile, "too-many-conditions", messages );
+ }
+
+}