diff --git a/proposal/myrmidon/src/java/org/apache/antlib/build/UpToDateCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/build/UpToDateCondition.java
new file mode 100644
index 000000000..aaf187139
--- /dev/null
+++ b/proposal/myrmidon/src/java/org/apache/antlib/build/UpToDateCondition.java
@@ -0,0 +1,130 @@
+/*
+ * 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.build;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import org.apache.myrmidon.api.TaskContext;
+import org.apache.myrmidon.api.TaskException;
+import org.apache.myrmidon.framework.FileNameMapper;
+import org.apache.myrmidon.framework.conditions.Condition;
+import org.apache.tools.todo.types.DirectoryScanner;
+import org.apache.tools.todo.types.FileSet;
+import org.apache.tools.todo.types.ScannerUtil;
+import org.apache.tools.todo.types.SourceFileScanner;
+import org.apache.tools.todo.util.mappers.MergingMapper;
+
+/**
+ * A condition which evaluates to true when the specified target has a
+ * timestamp greater than all of the source files.
+ *
+ * @author William Ferguson
+ * williamf@mincom.com
+ * @author Hiroaki Nakamura
+ * hnakamur@mc.neweb.ne.jp
+ * @author Stefan Bodewig
+ *
+ * @ant.type type="condition" name="uptodate"
+ */
+public class UpToDateCondition
+ implements Condition
+{
+ private final ArrayList m_fileSets = new ArrayList();
+ private FileNameMapper m_mapper;
+ private File m_targetFile;
+
+ /**
+ * The file which must be more up to date than each of the source files if
+ * the property is to be set.
+ *
+ * @param file the file which we are checking against.
+ */
+ public void setTargetFile( final File file )
+ {
+ m_targetFile = file;
+ }
+
+ /**
+ * Nested <srcfiles> element.
+ *
+ * @param fs The feature to be added to the Srcfiles attribute
+ */
+ public void addSrcfiles( final FileSet fs )
+ {
+ m_fileSets.add( fs );
+ }
+
+ /**
+ * Defines the FileNameMapper to use (nested mapper element).
+ */
+ public void add( final FileNameMapper mapper )
+ throws TaskException
+ {
+ if( m_mapper != null )
+ {
+ throw new TaskException( "Cannot define more than one mapper" );
+ }
+ m_mapper = mapper;
+ }
+
+ /**
+ * Evaluates this condition.
+ *
+ * @param context
+ * The context to evaluate the condition in.
+ */
+ public boolean evaluate( TaskContext context )
+ throws TaskException
+ {
+ if( m_targetFile == null && m_mapper == null )
+ {
+ throw new TaskException( "The targetfile attribute or a nested mapper element must be set" );
+ }
+
+ // if not there then it can't be up to date
+ if( m_targetFile != null && !m_targetFile.exists() )
+ {
+ return false;
+ }
+
+ final Iterator enum = m_fileSets.iterator();
+ while( enum.hasNext() )
+ {
+ final FileSet fs = (FileSet)enum.next();
+ final DirectoryScanner ds = ScannerUtil.getDirectoryScanner( fs );
+ if ( !scanDir( fs.getDir(), ds.getIncludedFiles(), context ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean scanDir( final File srcDir,
+ final String files[],
+ final TaskContext context )
+ throws TaskException
+ {
+ final SourceFileScanner scanner = new SourceFileScanner();
+ FileNameMapper mapper = null;
+ File dir = srcDir;
+ if( m_mapper == null )
+ {
+ final MergingMapper mm = new MergingMapper();
+ mm.setTo( m_targetFile.getAbsolutePath() );
+ mapper = mm;
+ dir = null;
+ }
+ else
+ {
+ mapper = m_mapper;
+ }
+ return scanner.restrict( files, srcDir, dir, mapper, context ).length == 0;
+ }
+}
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/core/Equals.java b/proposal/myrmidon/src/java/org/apache/antlib/core/Equals.java
new file mode 100644
index 000000000..819ae1c46
--- /dev/null
+++ b/proposal/myrmidon/src/java/org/apache/antlib/core/Equals.java
@@ -0,0 +1,53 @@
+package org.apache.antlib.core;
+
+/*
+ * 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.
+ */
+
+import org.apache.myrmidon.api.TaskException;
+import org.apache.myrmidon.api.TaskContext;
+import org.apache.myrmidon.framework.conditions.Condition;
+
+/**
+ * Simple String comparison condition.
+ *
+ * @author Stefan Bodewig
+ * @version $Revision$
+ *
+ * @ant.type type="condition" name="equals"
+ */
+public class Equals implements Condition
+{
+
+ private String arg1, arg2;
+
+ public void setArg1( String a1 )
+ {
+ arg1 = a1;
+ }
+
+ public void setArg2( String a2 )
+ {
+ arg2 = a2;
+ }
+
+ /**
+ * Evaluates this condition.
+ *
+ * @param context
+ * The context to evaluate the condition in.
+ */
+ public boolean evaluate( final TaskContext context )
+ throws TaskException
+ {
+ if( arg1 == null || arg2 == null )
+ {
+ throw new TaskException( "both arg1 and arg2 are required in equals" );
+ }
+ return arg1.equals( arg2 );
+ }
+}
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 518d73381..1e01b574d 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
+++ b/proposal/myrmidon/src/java/org/apache/antlib/core/IfTask.java
@@ -14,7 +14,7 @@ import org.apache.avalon.framework.configuration.Configuration;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.AbstractContainerTask;
import org.apache.myrmidon.framework.conditions.Condition;
-import org.apache.myrmidon.framework.conditions.IsSetCondition;
+import org.apache.myrmidon.framework.conditions.IsTrueCondition;
import org.apache.myrmidon.framework.conditions.NotCondition;
/**
@@ -44,7 +44,7 @@ public class IfTask
throws TaskException
{
verifyConditionNull();
- m_condition = new IsSetCondition( condition );
+ m_condition = new IsTrueCondition( condition );
}
/**
@@ -57,7 +57,7 @@ public class IfTask
throws TaskException
{
verifyConditionNull();
- m_condition = new NotCondition( new IsSetCondition( condition ) );
+ m_condition = new NotCondition( new IsTrueCondition( condition ) );
}
public void add( final Configuration task )
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/runtime/Resources.properties b/proposal/myrmidon/src/java/org/apache/antlib/runtime/Resources.properties
index a97ccadbb..b32f44b68 100644
--- a/proposal/myrmidon/src/java/org/apache/antlib/runtime/Resources.properties
+++ b/proposal/myrmidon/src/java/org/apache/antlib/runtime/Resources.properties
@@ -4,3 +4,7 @@ facility.no-namespace.error=Must specify namespace parameter.
import.no-lib.error=Must specify lib parameter.
import.no-deploy.error=Error importing tasklib.
+
+typeavailable.no-type-name.error=No type name was specified.
+typeavailable.unknown-role.error=Unknown role "{0}".
+typeavailable.evaluate.error=Could not determine if type "{0}" is available.
diff --git a/proposal/myrmidon/src/java/org/apache/antlib/runtime/TypeAvailableCondition.java b/proposal/myrmidon/src/java/org/apache/antlib/runtime/TypeAvailableCondition.java
new file mode 100644
index 000000000..29b7f410d
--- /dev/null
+++ b/proposal/myrmidon/src/java/org/apache/antlib/runtime/TypeAvailableCondition.java
@@ -0,0 +1,102 @@
+/*
+ * 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.runtime;
+
+import org.apache.myrmidon.framework.conditions.Condition;
+import org.apache.myrmidon.framework.DataType;
+import org.apache.myrmidon.api.TaskContext;
+import org.apache.myrmidon.api.TaskException;
+import org.apache.myrmidon.interfaces.role.RoleManager;
+import org.apache.myrmidon.interfaces.role.RoleInfo;
+import org.apache.myrmidon.interfaces.type.TypeManager;
+import org.apache.myrmidon.interfaces.type.TypeFactory;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+
+/**
+ * A condition that evaluates to true if a particular type is available.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ *
+ * @ant.type type="condition" name="type-available"
+ */
+public class TypeAvailableCondition
+ implements Condition
+{
+ private final static Resources REZ =
+ ResourceManager.getPackageResources( TypeAvailableCondition.class );
+
+ private String m_roleShorthand;
+ private String m_name;
+
+ /**
+ * Sets the role to search for.
+ */
+ public void setType( final String type )
+ {
+ m_roleShorthand = type;
+ }
+
+ /**
+ * Sets the type to search for.
+ */
+ public void setName( final String name )
+ {
+ m_name = name;
+ }
+
+ /**
+ * Evaluates this condition.
+ *
+ * @param context
+ * The context to evaluate the condition in.
+ */
+ public boolean evaluate( final TaskContext context )
+ throws TaskException
+ {
+ if( m_name == null )
+ {
+ final String message = REZ.getString( "typeavailable.no-type-name.error" );
+ throw new TaskException( message );
+ }
+
+ try
+ {
+ // Map the shorthand name to a role
+ final String roleName;
+ if( m_roleShorthand != null )
+ {
+ final RoleManager roleManager = (RoleManager)context.getService( RoleManager.class );
+ final RoleInfo roleInfo = roleManager.getRoleByShorthandName( m_roleShorthand );
+ if( roleInfo == null )
+ {
+ final String message = REZ.getString( "typeavailable.unknown-role.error", m_roleShorthand );
+ throw new TaskException( message );
+ }
+ roleName = roleInfo.getName();
+ }
+ else
+ {
+ roleName = DataType.ROLE;
+ }
+
+ // Lookup the type
+ final TypeManager typeManager = (TypeManager)context.getService( TypeManager.class );
+ final TypeFactory typeFactory = typeManager.getFactory( roleName );
+
+ // Check if the type is available
+ return typeFactory.canCreate( m_name );
+ }
+ catch( final Exception e )
+ {
+ final String message = REZ.getString( "typeavailable.evaluate.error", m_name );
+ throw new TaskException( message, e );
+ }
+ }
+}
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Pattern.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Pattern.java
index c536935ba..cfeeca65e 100644
--- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Pattern.java
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/Pattern.java
@@ -12,7 +12,7 @@ import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.conditions.Condition;
-import org.apache.myrmidon.framework.conditions.IsSetCondition;
+import org.apache.myrmidon.framework.conditions.IsTrueCondition;
import org.apache.myrmidon.framework.conditions.NotCondition;
/**
@@ -80,7 +80,7 @@ public class Pattern
throws TaskException
{
verifyConditionNull();
- m_condition = new IsSetCondition( condition );
+ m_condition = new IsTrueCondition( condition );
}
/**
@@ -93,7 +93,7 @@ public class Pattern
throws TaskException
{
verifyConditionNull();
- m_condition = new NotCondition( new IsSetCondition( condition ) );
+ m_condition = new NotCondition( new IsTrueCondition( condition ) );
}
public String evaluateName( final TaskContext context )
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/IsSetCondition.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/IsSetCondition.java
index afbe23566..2d26a907b 100644
--- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/IsSetCondition.java
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/IsSetCondition.java
@@ -13,8 +13,7 @@ import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
/**
- * A {@link Condition} that is true when a property is set, but not set to
- * 'false'.
+ * A {@link Condition} that is true when a property is set.
*
* @author Stefan Bodewig
* @author Peter Donald
@@ -62,6 +61,6 @@ public class IsSetCondition
// Resolve the condition
final Object object = context.getProperty( m_property );
- return ( object != null && !object.toString().equals( "false" ) );
+ return ( object != null );
}
}
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/IsTrueCondition.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/IsTrueCondition.java
new file mode 100644
index 000000000..1772659b7
--- /dev/null
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/IsTrueCondition.java
@@ -0,0 +1,84 @@
+/*
+ * 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.myrmidon.framework.conditions;
+
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.myrmidon.api.TaskContext;
+import org.apache.myrmidon.api.TaskException;
+import org.apache.aut.converter.Converter;
+import org.apache.aut.converter.ConverterException;
+
+/**
+ * A {@link Condition} that is true when a property is set, but not set to
+ * 'false'.
+ *
+ * @author Stefan Bodewig
+ * @author Peter Donald
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ *
+ * @ant.type type="condition" name="is-true"
+ */
+public class IsTrueCondition
+ implements Condition
+{
+ private final static Resources REZ =
+ ResourceManager.getPackageResources( IsTrueCondition.class );
+
+ private String m_property;
+
+ public IsTrueCondition( final String propName )
+ {
+ m_property = propName;
+ }
+
+ public IsTrueCondition()
+ {
+ }
+
+ /**
+ * Set the property name to test.
+ */
+ public void setProperty( final String propName )
+ {
+ m_property = propName;
+ }
+
+ /**
+ * Evaluates the condition.
+ */
+ public boolean evaluate( final TaskContext context )
+ throws TaskException
+ {
+ if( m_property == null )
+ {
+ final String message = REZ.getString( "isset.no-property.error" );
+ throw new TaskException( message );
+ }
+
+ // Resolve the property name
+ final Object object = context.getProperty( m_property );
+ if( object == null )
+ {
+ return false;
+ }
+
+ // Convert value to boolean
+ try
+ {
+ final Converter converter = (Converter)context.getService( Converter.class );
+ final Boolean value = (Boolean)converter.convert( Boolean.class, object, context );
+ return value.booleanValue();
+ }
+ catch( final ConverterException e )
+ {
+ throw new TaskException( e.getMessage(), e );
+ }
+ }
+}
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/NotCondition.java b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/NotCondition.java
index 45abef4f3..cf36a93ae 100644
--- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/NotCondition.java
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/NotCondition.java
@@ -9,6 +9,8 @@ package org.apache.myrmidon.framework.conditions;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.api.TaskException;
+import org.apache.avalon.excalibur.i18n.ResourceManager;
+import org.apache.avalon.excalibur.i18n.Resources;
/**
* <not> condition. Evaluates to true if the single condition nested into
@@ -22,6 +24,9 @@ import org.apache.myrmidon.api.TaskException;
public class NotCondition
implements Condition
{
+ private final static Resources REZ =
+ ResourceManager.getPackageResources( NotCondition.class );
+
private Condition m_condition;
public NotCondition()
@@ -34,10 +39,16 @@ public class NotCondition
}
/**
- * Sets the nested condition.
+ * Adds a nested condition.
*/
- public void set( final Condition condition )
+ public void add( final Condition condition )
+ throws TaskException
{
+ if( m_condition != null )
+ {
+ final String message = REZ.getString( "not.too-many-conditions.error" );
+ throw new TaskException( message );
+ }
m_condition = condition;
}
@@ -49,7 +60,8 @@ public class NotCondition
{
if( m_condition == null )
{
- throw new TaskException( "no condition set" );
+ final String message = REZ.getString( "not.no-condition.error" );
+ throw new TaskException( message );
}
return ! m_condition.evaluate( context );
diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/Resources.properties b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/Resources.properties
index 10b859f0f..8a3743cd7 100644
--- a/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/Resources.properties
+++ b/proposal/myrmidon/src/java/org/apache/myrmidon/framework/conditions/Resources.properties
@@ -1 +1,4 @@
isset.no-property.error=No property specified to test.
+istrue.no-property.error=No property specified to test.
+not.no-condition.error=No condition specified.
+not.too-many-conditions.error=Too many conditions specified.
\ No newline at end of file
diff --git a/proposal/myrmidon/src/test/org/apache/antlib/core/test/IfTestCase.java b/proposal/myrmidon/src/test/org/apache/antlib/core/test/IfTestCase.java
index b71d5fd4d..11b489033 100644
--- a/proposal/myrmidon/src/test/org/apache/antlib/core/test/IfTestCase.java
+++ b/proposal/myrmidon/src/test/org/apache/antlib/core/test/IfTestCase.java
@@ -42,9 +42,7 @@ public class IfTestCase
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 );
+ executeTargetExpectError( projectFile, "set-prop", new String[0] );
// Test when property is set to 'false'
listener = new LogMessageTracker();
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractMyrmidonTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractMyrmidonTest.java
index fbef96e5a..ce0fb3738 100644
--- a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractMyrmidonTest.java
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractMyrmidonTest.java
@@ -127,7 +127,7 @@ public abstract class AbstractMyrmidonTest
/**
* Returns the directory containing a Myrmidon install.
*/
- protected File getHomeDirectory()
+ protected File getInstallDirectory()
{
final File file = new File( m_baseDir, "dist" );
return getCanonicalFile( file );
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java
index 371e341da..e23c282a4 100644
--- a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java
@@ -59,7 +59,7 @@ public class AbstractProjectTest
m_embeddor.enableLogging( logger );
final Parameters params = new Parameters();
- final File instDir = getHomeDirectory();
+ final File instDir = getInstallDirectory();
params.setParameter( "myrmidon.home", instDir.getAbsolutePath() );
m_embeddor.parameterize( params );
m_embeddor.initialize();
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/AndConditionTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/AndConditionTestCase.java
new file mode 100644
index 000000000..dff1aebb5
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/AndConditionTestCase.java
@@ -0,0 +1,37 @@
+/*
+ * 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.myrmidon.framework.conditions.test;
+
+import java.io.File;
+import org.apache.myrmidon.AbstractProjectTest;
+
+/**
+ * Test cases for the condition.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+public class AndConditionTestCase
+ extends AbstractProjectTest
+{
+ public AndConditionTestCase( final String name )
+ {
+ super( name );
+ }
+
+ /**
+ * Tests evaluation of the condition.
+ */
+ public void testEvaluation() throws Exception
+ {
+ final File projectFile = getTestResource( "and.ant" );
+ executeTarget( projectFile, "empty" );
+ executeTarget( projectFile, "truth-table" );
+ executeTarget( projectFile, "lazy" );
+ }
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/ConditionTestTask.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/ConditionTestTask.java
new file mode 100644
index 000000000..5dad5a06e
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/ConditionTestTask.java
@@ -0,0 +1,50 @@
+/*
+ * 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.myrmidon.framework.conditions.test;
+
+import org.apache.myrmidon.api.AbstractTask;
+import org.apache.myrmidon.api.TaskException;
+import org.apache.myrmidon.framework.conditions.Condition;
+
+/**
+ * A simple assert task, used for testing conditions.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ *
+ * @ant.task name="assert"
+ */
+public class ConditionTestTask
+ extends AbstractTask
+{
+ private boolean m_expected = true;
+ private Condition m_condition;
+
+ public void setExpected( final boolean expected )
+ {
+ m_expected = expected;
+ }
+
+ public void add( final Condition condition )
+ {
+ m_condition = condition;
+ }
+
+ /**
+ * Execute task.
+ */
+ public void execute()
+ throws TaskException
+ {
+ final boolean result = m_condition.evaluate( getContext() );
+ if( result != m_expected )
+ {
+ throw new TaskException( "Expected " + m_expected + ", got " + result );
+ }
+ }
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/IsSetConditionTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/IsSetConditionTestCase.java
new file mode 100644
index 000000000..547109a1a
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/IsSetConditionTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * 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.myrmidon.framework.conditions.test;
+
+import java.io.File;
+import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.myrmidon.AbstractProjectTest;
+import org.apache.myrmidon.framework.conditions.IsSetCondition;
+
+/**
+ * Test cases for the condition.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+public class IsSetConditionTestCase
+ extends AbstractProjectTest
+{
+ public IsSetConditionTestCase( final String name )
+ {
+ super( name );
+ }
+
+ /**
+ * Test cases for evaluation.
+ */
+ public void testEvaluation() throws Exception
+ {
+ final File projectFile = getTestResource( "isset.ant" );
+ executeTarget( projectFile, "set" );
+ executeTarget( projectFile, "set2true" );
+ executeTarget( projectFile, "set2false" );
+ executeTarget( projectFile, "not-set" );
+
+ Resources res = getResourcesForTested( IsSetCondition.class );
+ final String[] messages = {
+ null,
+ res.getString( "isset.no-property.error" )
+ };
+ executeTargetExpectError( projectFile, "no-prop-name", messages );
+ }
+
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/IsTrueConditionTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/IsTrueConditionTestCase.java
new file mode 100644
index 000000000..2b5db75ae
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/IsTrueConditionTestCase.java
@@ -0,0 +1,51 @@
+/*
+ * 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.myrmidon.framework.conditions.test;
+
+import java.io.File;
+import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.myrmidon.AbstractProjectTest;
+import org.apache.myrmidon.framework.conditions.IsTrueCondition;
+
+/**
+ * Test cases for the condition.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+public class IsTrueConditionTestCase
+ extends AbstractProjectTest
+{
+ public IsTrueConditionTestCase( final String name )
+ {
+ super( name );
+ }
+
+ /**
+ * Test cases for evaluation.
+ */
+ public void testEvaluation() throws Exception
+ {
+ final File projectFile = getTestResource( "istrue.ant" );
+ executeTarget( projectFile, "set2true" );
+ executeTarget( projectFile, "set2false" );
+ executeTarget( projectFile, "not-set" );
+
+ // TODO - check error message
+ String[] messages = {};
+ executeTargetExpectError( projectFile, "set", messages );
+
+ final Resources res = getResourcesForTested( IsTrueCondition.class );
+ messages = new String[] {
+ null,
+ res.getString( "istrue.no-property.error" )
+ };
+ executeTargetExpectError( projectFile, "no-prop-name", messages );
+ }
+
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/NotConditionTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/NotConditionTestCase.java
new file mode 100644
index 000000000..38e60c03e
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/NotConditionTestCase.java
@@ -0,0 +1,39 @@
+/*
+ * 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.myrmidon.framework.conditions.test;
+
+import org.apache.myrmidon.AbstractProjectTest;
+import java.io.File;
+
+/**
+ * Test cases for the condition.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+public class NotConditionTestCase
+ extends AbstractProjectTest
+{
+ public NotConditionTestCase( final String name )
+ {
+ super( name );
+ }
+
+ /**
+ * Tests evaluation of .
+ */
+ public void testEvaluation() throws Exception
+ {
+ final File projectFile = getTestResource( "not.ant" );
+ executeTarget( projectFile, "truth-table" );
+
+ // TODO - check error messages
+ executeTargetExpectError( projectFile, "empty", new String[0] );
+ executeTargetExpectError( projectFile, "too-many-nested", new String[0] );
+ }
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/OrConditionTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/OrConditionTestCase.java
new file mode 100644
index 000000000..c8e90e3c0
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/OrConditionTestCase.java
@@ -0,0 +1,37 @@
+/*
+ * 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.myrmidon.framework.conditions.test;
+
+import java.io.File;
+import org.apache.myrmidon.AbstractProjectTest;
+
+/**
+ * Test cases for the condition.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ */
+public class OrConditionTestCase
+ extends AbstractProjectTest
+{
+ public OrConditionTestCase( final String name )
+ {
+ super( name );
+ }
+
+ /**
+ * Tests evaluation of the condition.
+ */
+ public void testEvaluation() throws Exception
+ {
+ final File projectFile = getTestResource( "or.ant" );
+ executeTarget( projectFile, "empty" );
+ executeTarget( projectFile, "truth-table" );
+ executeTarget( projectFile, "lazy" );
+ }
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/TestCondition.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/TestCondition.java
new file mode 100644
index 000000000..9adbb9e61
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/TestCondition.java
@@ -0,0 +1,57 @@
+/*
+ * 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.myrmidon.framework.conditions.test;
+
+import org.apache.myrmidon.framework.conditions.Condition;
+import org.apache.myrmidon.api.TaskContext;
+import org.apache.myrmidon.api.TaskException;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+/**
+ * A condition used for testing.
+ *
+ * @author Adam Murdoch
+ * @version $Revision$ $Date$
+ *
+ * @ant.type type="condition" name="true"
+ * @ant.type type="condition" name="false"
+ * @ant.type type="condition" name="fail"
+ */
+public class TestCondition
+ implements Condition, Configurable
+{
+ private String m_action;
+
+ public void configure( final Configuration configuration )
+ throws ConfigurationException
+ {
+ m_action = configuration.getName();
+ }
+
+ /**
+ * Evaluates this condition.
+ */
+ public boolean evaluate( final TaskContext context )
+ throws TaskException
+ {
+ if( m_action.equalsIgnoreCase( "true" ) )
+ {
+ return true;
+ }
+ else if( m_action.equalsIgnoreCase( "false" ) )
+ {
+ return false;
+ }
+ else
+ {
+ throw new TaskException( "Fail." );
+ }
+ }
+}
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/and.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/and.ant
new file mode 100644
index 000000000..52cae89ca
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/and.ant
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/isset.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/isset.ant
new file mode 100644
index 000000000..d0a48377d
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/isset.ant
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/istrue.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/istrue.ant
new file mode 100644
index 000000000..c1f3770f5
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/istrue.ant
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/not.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/not.ant
new file mode 100644
index 000000000..ea134d363
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/not.ant
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/or.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/or.ant
new file mode 100644
index 000000000..1ed408722
--- /dev/null
+++ b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/or.ant
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file