diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractMyrmidonTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractMyrmidonTest.java deleted file mode 100644 index 26b2035bf..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractMyrmidonTest.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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; - -import java.io.File; -import java.io.IOException; -import junit.framework.TestCase; -import org.apache.avalon.excalibur.i18n.Resources; -import org.apache.avalon.excalibur.i18n.ResourceManager; -import org.apache.avalon.framework.ExceptionUtil; -import org.apache.avalon.framework.logger.Logger; -import org.apache.myrmidon.frontends.BasicLogger; - -/** - * A base class for Myrmidon tests. Provides utility methods for locating - * test resources. - * - * @author Adam Murdoch - */ -public abstract class AbstractMyrmidonTest - extends TestCase -{ - private final File m_testBaseDir; - private final File m_baseDir; - private Logger m_logger; - - public AbstractMyrmidonTest( final String name ) - { - super( name ); - final String baseDirProp = System.getProperty( "test.basedir" ); - m_baseDir = getCanonicalFile( new File( baseDirProp ) ); - final String packagePath = getPackageName( getClass() ).replace( '.', File.separatorChar ); - m_testBaseDir = getCanonicalFile( new File( m_baseDir, packagePath ) ); - } - - /** - * Locates the error message resources for a class. - */ - protected static final Resources getResourcesForTested( final Class clazz ) - { - String baseName = getPackageName( clazz ); - if( baseName.endsWith( ".test" ) ) - { - baseName = baseName.substring( 0, baseName.length() - 5 ); - } - - return ResourceManager.getBaseResources( baseName + ".Resources", AbstractMyrmidonTest.class.getClassLoader() ); - } - - /** - * Returns the name of the package containing a class. - * - * @return The . delimited package name, or an empty string if the class - * is in the default package. - */ - protected static String getPackageName( final Class clazz ) - { - final Package pkg = clazz.getPackage(); - if( null != pkg ) - { - return pkg.getName(); - } - - final String name = clazz.getName(); - if( -1 == name.lastIndexOf( "." ) ) - { - return ""; - } - else - { - return name.substring( 0, name.lastIndexOf( "." ) ); - } - } - - /** - * Locates a test resource, and asserts that the resource exists - * - * @param name path of the resource, relative to this test's base directory. - */ - protected File getTestResource( final String name ) - { - return getTestResource( name, true ); - } - - /** - * Locates a test resource. - * - * @param name path of the resource, relative to this test's base directory. - */ - protected File getTestResource( final String name, final boolean mustExist ) - { - File file = new File( m_testBaseDir, name ); - file = getCanonicalFile( file ); - if( mustExist ) - { - assertTrue( "Test file \"" + file + "\" does not exist.", file.exists() ); - } - else - { - assertTrue( "Test file \"" + file + "\" should not exist.", !file.exists() ); - } - - return file; - } - - /** - * Locates the base directory for this test. - */ - protected File getTestDirectory() - { - return m_testBaseDir; - } - - /** - * Locates a test directory, creating it if it does not exist. - * - * @param name path of the directory, relative to this test's base directory. - */ - protected File getTestDirectory( final String name ) - { - File file = new File( m_testBaseDir, name ); - file = getCanonicalFile( file ); - assertTrue( "Test directory \"" + file + "\" does not exist or is not a directory.", - file.isDirectory() || file.mkdirs() ); - return file; - } - - /** - * Returns the directory containing a Myrmidon install. - */ - protected File getInstallDirectory() - { - final File file = new File( m_baseDir, "dist" ); - return getCanonicalFile( file ); - } - - /** - * Makes a file canonical - */ - private File getCanonicalFile( final File file ) - { - try - { - return file.getCanonicalFile(); - } - catch( IOException e ) - { - return file.getAbsoluteFile(); - } - } - - /** - * Creates a logger. - */ - protected Logger getLogger() - { - if( m_logger == null ) - { - m_logger = new BasicLogger( "[test]", BasicLogger.LEVEL_WARN ); - } - return m_logger; - } - - /** - * Asserts that an exception chain contains the expected messages. - * - * @param messages The messages, in order. A null entry in this array - * indicates that the message should be ignored. - */ - protected void assertSameMessage( final String[] messages, final Throwable throwable ) - { - Throwable current = throwable; - for( int i = 0; i < messages.length; i++ ) - { - String message = messages[ i ]; - assertNotNull( current ); - if( message != null ) - { - assertEquals( message, current.getMessage() ); - } - - // Get the next exception in the chain - current = ExceptionUtil.getCause( current, true ); - } - } - - /** - * Asserts that an exception contains the expected message. - */ - protected void assertSameMessage( final String message, final Throwable throwable ) - { - assertSameMessage( new String[]{message}, throwable ); - } - - /** - * Compares 2 objects for equality, nulls are equal. Used by the test - * classes' equals() methods. - */ - public static boolean equals( final Object o1, final Object o2 ) - { - if( o1 == null && o2 == null ) - { - return true; - } - if( o1 == null || o2 == null ) - { - return false; - } - return o1.equals( o2 ); - } - -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java b/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java deleted file mode 100644 index 11469badb..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/AbstractProjectTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * 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; - -import java.io.File; -import org.apache.myrmidon.frontends.EmbeddedAnt; -import org.apache.myrmidon.listeners.ProjectListener; -import org.apache.avalon.framework.ExceptionUtil; - -/** - * A base class for test cases which need to execute projects. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class AbstractProjectTest - extends AbstractMyrmidonTest -{ - public AbstractProjectTest( final String name ) - { - super( name ); - } - - /** - * Executes a target in a project, and asserts that it fails with the - * given error message. - */ - protected void executeTargetExpectError( final File projectFile, - final String targetName, - final String message ) - { - executeTargetExpectError( projectFile, targetName, new String[]{message} ); - } - - /** - * Executes a target in a project, and asserts that it fails with the - * given error messages. - */ - protected void executeTargetExpectError( final File projectFile, - final String targetName, - final String[] messages ) - { - try - { - executeTarget( projectFile, targetName, null ); - fail( "target execution did not fail" ); - } - catch( Exception e ) - { - assertSameMessage( messages, e ); - } - } - - /** - * Executes a target in a project, and asserts that it does not fail. - */ - protected void executeTarget( final File projectFile, final String targetName ) - throws Exception - { - executeTarget( projectFile, targetName, null ); - } - - /** - * Executes a target in a project, and asserts that it does not fail. - */ - protected void executeTarget( final File projectFile, - final String targetName, - final ProjectListener listener ) - throws Exception - { - final EmbeddedAnt embeddor = new EmbeddedAnt(); - final TrackingProjectListener tracker = new TrackingProjectListener(); - - try - { - // Configure embeddor - embeddor.setHomeDirectory( getInstallDirectory() ); - embeddor.enableLogging( getLogger() ); - embeddor.setSharedClassLoader( getClass().getClassLoader() ); - embeddor.setProjectFile( projectFile.getAbsolutePath() ); - embeddor.setProjectListener( null ); - - // Add a listener to make sure all is good - embeddor.addProjectListener( tracker ); - - // Add supplied listener - if( listener != null ) - { - embeddor.addProjectListener( listener ); - } - - // Now execute the target - embeddor.executeTargets( new String[] { targetName } ); - } - finally - { - embeddor.stop(); - } - - - // Make sure all expected events were delivered - tracker.assertComplete(); - if( listener instanceof TrackingProjectListener ) - { - ( (TrackingProjectListener)listener ).assertComplete(); - } - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/LogMessageTracker.java b/proposal/myrmidon/src/test/org/apache/myrmidon/LogMessageTracker.java deleted file mode 100644 index be5f53b04..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/LogMessageTracker.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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; - -import java.util.ArrayList; -import java.util.List; -import org.apache.myrmidon.listeners.LogEvent; - -/** - * Asserts that log messages are delivered in the correct order. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class LogMessageTracker - extends TrackingProjectListener -{ - private List m_targets = new ArrayList(); - private List m_messages = new ArrayList(); - - /** - * Handles a log message. - */ - public void log( final LogEvent event ) - { - super.log( event ); - - // Pop the next expected message off the list, and make sure it - // matches the message in the event - assertTrue( "Unexpected log message", m_targets.size() > 0 && m_messages.size() > 0 ); - assertEquals( "Unexpected log message", m_targets.remove( 0 ), event.getTargetName() ); - assertEquals( "Unexpected log message", m_messages.remove( 0 ), event.getMessage() ); - } - - /** - * Asserts that all the log messages were delivered. - */ - public void assertComplete() - { - super.assertComplete(); - - // Make sure that all log messages were delivered - assertTrue( "Log message not delivered", m_targets.size() == 0 && m_messages.size() == 0 ); - } - - /** - * Adds an expected log message. - */ - public void addExpectedMessage( String target, String message ) - { - m_targets.add( target ); - m_messages.add( message ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/TrackingProjectListener.java b/proposal/myrmidon/src/test/org/apache/myrmidon/TrackingProjectListener.java deleted file mode 100644 index 9ddf03f1f..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/TrackingProjectListener.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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; - -import junit.framework.Assert; -import org.apache.myrmidon.listeners.LogEvent; -import org.apache.myrmidon.listeners.ProjectEvent; -import org.apache.myrmidon.listeners.ProjectListener; -import org.apache.myrmidon.listeners.TargetEvent; -import org.apache.myrmidon.listeners.TaskEvent; - -/** - * A project listener that asserts that it receives a particular sequence of - * events. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class TrackingProjectListener - extends Assert - implements ProjectListener -{ - private String m_rootProject; - private String m_currentProject; - private String m_currentTarget; - private String m_currentTask; - - /** - * Notify the listener that a project is about to start. - */ - public void projectStarted( final ProjectEvent event ) - { - assertNull( "Project already started", m_rootProject ); - m_rootProject = event.getProjectName(); - } - - /** - * Notify the listener that a project has finished. - */ - public void projectFinished( final ProjectEvent event ) - { - assertEquals( "Mismatched project name", m_rootProject, event.getProjectName() ); - m_rootProject = null; - - assertNull( "Target not started", m_currentTarget ); - } - - /** - * Notify the listener that a target is about to start. - */ - public void targetStarted( final TargetEvent event ) - { - assertNotNull( "Project not started", m_rootProject ); - assertNull( "Target already started", m_currentTarget ); - m_currentProject = event.getProjectName(); - m_currentTarget = event.getTargetName(); - } - - /** - * Notify the listener that a target has finished. - */ - public void targetFinished( final TargetEvent event ) - { - assertEquals( "Mismatched project name", m_currentProject, event.getProjectName() ); - assertEquals( "Mismatched target name", m_currentTarget, event.getTargetName() ); - m_currentProject = null; - m_currentTarget = null; - - assertNull( "Task not finished", m_currentTask ); - } - - /** - * Notify the listener that a task is about to start. - */ - public void taskStarted( final TaskEvent event ) - { - assertEquals( "Mismatched project name", m_currentProject, event.getProjectName() ); - assertEquals( "Mismatched target name", m_currentTarget, event.getTargetName() ); - - assertNull( "Task already started", m_currentTask ); - m_currentTask = event.getTaskName(); - } - - /** - * Notify the listener that a task has finished. - */ - public void taskFinished( final TaskEvent event ) - { - assertEquals( "Mismatched project name", m_currentProject, event.getProjectName() ); - assertEquals( "Mismatched target name", m_currentTarget, event.getTargetName() ); - assertEquals( "Mismatched task name", m_currentTask, event.getTaskName() ); - m_currentTask = null; - } - - /** - * Notify listener of log message event. - */ - public void log( final LogEvent event ) - { - assertEquals( "Mismatched project name", m_currentProject, event.getProjectName() ); - assertEquals( "Mismatched target name", m_currentTarget, event.getTargetName() ); - assertEquals( "Mismatched task name", m_currentTask, event.getTaskName() ); - assertNull( "Unexpected build error", event.getThrowable() ); - } - - /** - * Asserts that the listener has finished. - */ - public void assertComplete() - { - assertNull( "Task not finished", m_currentTask ); - assertNull( "Target not finished", m_currentTarget ); - assertNull( "Target not finished", m_currentProject ); - assertNull( "Project not finished", m_rootProject ); - } -} 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 deleted file mode 100644 index dff1aebb5..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/AndConditionTestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5dad5a06e..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/ConditionTestTask.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 deleted file mode 100644 index 547109a1a..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/IsSetConditionTestCase.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2b5db75ae..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/IsTrueConditionTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 deleted file mode 100644 index 38e60c03e..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/NotConditionTestCase.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 deleted file mode 100644 index c8e90e3c0..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/OrConditionTestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 deleted file mode 100644 index 9adbb9e61..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/TestCondition.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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 deleted file mode 100644 index 52cae89ca..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/and.ant +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ 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 deleted file mode 100644 index d0a48377d..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/isset.ant +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index c1f3770f5..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/istrue.ant +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index ea134d363..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/not.ant +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ 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 deleted file mode 100644 index 1ed408722..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/conditions/test/or.ant +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/PathTestCase.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/PathTestCase.java deleted file mode 100644 index e23055298..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/PathTestCase.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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.file.test; - -import java.io.File; -import org.apache.aut.nativelib.PathUtil; -import org.apache.avalon.excalibur.io.FileUtil; -import org.apache.myrmidon.AbstractProjectTest; -import org.apache.myrmidon.LogMessageTracker; - -/** - * Test-cases for the data type. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - */ -public class PathTestCase - extends AbstractProjectTest -{ - public PathTestCase( final String name ) - { - super( name ); - } - - /** - * Tests setting the location attribute. - */ - public void testLocationAttribute() throws Exception - { - testPathContent( "set-location", new String[]{"location"} ); - } - - /** - * Tests setting the path attribute. - */ - public void testPathAttribute() throws Exception - { - // Test a path with a single file - testPathContent( "set-path", new String[]{"single-file"} ); - - // Test a path with several files, using ; separator - testPathContent( "set-multi-path", new String[]{"file1", "file2", ".."} ); - - // Test a path with several files, using : separator - testPathContent( "set-multi-path2", new String[]{"file1", "file2", ".."} ); - } - - /** - * Test using nested elements. - */ - public void testPathElement() throws Exception - { - testPathContent( "nested-path", new String[]{"some-file"} ); - testPathContent( "mixed-path", new String[]{"file1", "file2", "file3", "file4", "file5"} ); - } - - /** - * Test using nested elements. - */ - public void testFilesetElement() throws Exception - { - testPathContent( "set-fileset", new String[]{"path.ant"} ); - } - - /** - * Test using a nested custom file list implementation. - */ - public void testCustomFileList() throws Exception - { - testPathContent( "test-custom-file-list", new String[]{"file1"} ); - } - - /** - * Test converting between string and path. - */ - public void testConvert() throws Exception - { - testPathContent( "convert-string-to-path", new String[]{"file1", "file2"} ); - - // Test conversion from path -> string - final File[] files = { - getTestResource( "file1", false ), - getTestResource( "file2", false ) - }; - final String path = PathUtil.formatPath( files ); - final LogMessageTracker listener = new LogMessageTracker(); - listener.addExpectedMessage( "convert-path-to-string", "test-path = " + path ); - - final File projectFile = getTestResource( "path.ant" ); - executeTarget( projectFile, "convert-path-to-string", listener ); - } - - /** - * Executes a target, and asserts that a particular list of file names - * is logged. - */ - private void testPathContent( final String targetName, - final String[] files ) throws Exception - { - final File projectFile = getTestResource( "path.ant" ); - final File baseDir = projectFile.getParentFile(); - - // Add each of the expected file names - final LogMessageTracker listener = new LogMessageTracker(); - for( int i = 0; i < files.length; i++ ) - { - final String fileName = files[ i ]; - final File file = FileUtil.resolveFile( baseDir, fileName ); - listener.addExpectedMessage( targetName, file.getAbsolutePath() ); - } - - // Execute the target - executeTarget( projectFile, targetName, listener ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/TestFileList.java b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/TestFileList.java deleted file mode 100644 index 8ca76f0e7..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/TestFileList.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.file.test; - -import java.io.File; -import java.util.ArrayList; -import org.apache.myrmidon.api.TaskContext; -import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.framework.file.FileList; -import org.apache.myrmidon.framework.file.Path; - -/** - * A test FileList implementation. - * - * @author Adam Murdoch - * @version $Revision$ $Date$ - * - * @ant.type type="path" name="test-file-list" - */ -public class TestFileList - implements FileList -{ - private String m_name; - private Path m_path; - - public void setName( final String name ) - { - m_name = name; - } - - public void setPath( final Path path ) - { - m_path = path; - } - - /** - * Returns the files in this list. - */ - public String[] listFiles( final TaskContext context ) - throws TaskException - { - final ArrayList files = new ArrayList(); - if( m_name != null ) - { - final File file = context.resolveFile( m_name ); - files.add( file.getAbsolutePath() ); - } - if( m_path != null ) - { - final String[] fileNames = m_path.listFiles( context ); - for( int i = 0; i < fileNames.length; i++ ) - { - files.add( fileNames[ i ] ); - } - } - return (String[])files.toArray( new String[ files.size() ] ); - } -} diff --git a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/path.ant b/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/path.ant deleted file mode 100644 index 006c3f441..000000000 --- a/proposal/myrmidon/src/test/org/apache/myrmidon/framework/file/test/path.ant +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - test-path = ${test-path} - - - \ No newline at end of file diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/Ant1CompatTestCase.java b/proposal/myrmidon/src/test/org/apache/tools/ant/test/Ant1CompatTestCase.java deleted file mode 100644 index 333cc54f7..000000000 --- a/proposal/myrmidon/src/test/org/apache/tools/ant/test/Ant1CompatTestCase.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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.tools.ant.test; - -import java.io.File; -import org.apache.myrmidon.AbstractProjectTest; -import org.apache.myrmidon.LogMessageTracker; - -/** - * Simple tests for the Ant1 Compatibility layer. - * - * @author Darrell DeBoer - * @version $Revision$ $Date$ - */ -public class Ant1CompatTestCase - extends AbstractProjectTest -{ - public Ant1CompatTestCase( final String name ) - { - super( name ); - } - - public void testBasic() throws Exception - { - final File projectFile = getTestResource( "basic-test.xml" ); - - // test - LogMessageTracker tracker = new LogMessageTracker(); - tracker.addExpectedMessage( "echo-test", "Hello, hello, hello" ); - executeTarget( projectFile, "echo-test", tracker ); - - // Property resolution tests - tracker = new LogMessageTracker(); - tracker.addExpectedMessage( "property-test", "prop-1 = [value-1]" ); - tracker.addExpectedMessage( "property-test", "prop-2 = [value-2]" ); - tracker.addExpectedMessage( "property-test", "prop-undefined = [${prop-undefined}]" ); - tracker.addExpectedMessage( "property-test", "Omit, replace$, but keep ${} and $" ); - executeTarget( projectFile, "property-test", tracker ); - } - - public void testIfUnless() throws Exception - { - final File projectFile = getTestResource( "if-unless-test.xml" ); - - // if/unless tests. - LogMessageTracker tracker = new LogMessageTracker(); - // Should pass if for "set", "true" and "false" - tracker.addExpectedMessage( "if-set-test", "Ran target: if-set-test" ); - tracker.addExpectedMessage( "if-true-test", "Ran target: if-true-test" ); - tracker.addExpectedMessage( "if-false-test", "Ran target: if-false-test" ); - - // Should only pass unless, when not defined. - tracker.addExpectedMessage( "unless-unset-test", - "Ran target: unless-unset-test" ); - - // If combined with unless on a single target. - tracker.addExpectedMessage( "if-with-unless-test-1", - "Ran target: if-with-unless-test-1" ); - - executeTarget( projectFile, "if-unless-tests", tracker ); - } - - public void testAntTask() throws Exception - { - final File projectFile = getTestResource( "ant-task-test.xml" ); - - // TODO - Get the project listeners working, so we can test log messages. - - LogMessageTracker tracker = new LogMessageTracker(); - tracker.addExpectedMessage( "default-target", "In default target." ); - tracker.addExpectedMessage( "echo-test", "Hello, hello, hello" ); - // executeTarget( projectFile, "ant-samefile-test", tracker ); - executeTarget( projectFile, "ant-samefile-test" ); - - tracker = new LogMessageTracker(); - tracker.addExpectedMessage( "main", - "Executed subdir/build.xml (default target)" ); - tracker.addExpectedMessage( "main", - "Executed subdir/build.xml (default target)" ); - tracker.addExpectedMessage( "main", - "Executed subdir/build.xml (default target)" ); - tracker.addExpectedMessage( "echo", - "Executed subdir/build.xml (echo target)" ); - // executeTarget( projectFile, "ant-otherfile-test", tracker ); - executeTarget( projectFile, "ant-otherfile-test" ); - - tracker = new LogMessageTracker(); - tracker.addExpectedMessage( "property-test", - "test-prop = [test-value]" ); - tracker.addExpectedMessage( "property-test", - "test-prop = [set in calling task]" ); - tracker.addExpectedMessage( "property-test", - "test-prop = [set in calling target]" ); - tracker.addExpectedMessage( "property-test", - "test-prop = [test-value]" ); - // executeTarget( projectFile, "ant-setprops-test", tracker ); - executeTarget( projectFile, "ant-setprops-test" ); - } - - public void testAntcallTask() throws Exception - { - final File projectFile = getTestResource( "antcall-task-test.xml" ); - - // TODO - Get the project listeners working, so we can test log messages. - - LogMessageTracker tracker = new LogMessageTracker(); - tracker.addExpectedMessage( "default-target", - "In default target." ); - tracker.addExpectedMessage( "antcall-target", - "In antcall-target: test-prop = [test-value]" ); - tracker.addExpectedMessage( "antcall-target", - "In antcall-target: test-prop = [set in calling task]" ); - tracker.addExpectedMessage( "antcall-target", - "In antcall-target: test-prop = [set in calling target]" ); - tracker.addExpectedMessage( "antcall-target", - "In antcall-target: test-prop = [test-value]" ); - // executeTarget( projectFile, "ant-samefile-test", tracker ); - executeTarget( projectFile, "antcall-test" ); - } - -} diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/ant-task-test.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/ant-task-test.xml deleted file mode 100644 index a867e8f69..000000000 --- a/proposal/myrmidon/src/test/org/apache/tools/ant/test/ant-task-test.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/antcall-task-test.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/antcall-task-test.xml deleted file mode 100644 index fbcf82de2..000000000 --- a/proposal/myrmidon/src/test/org/apache/tools/ant/test/antcall-task-test.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/basic-test.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/basic-test.xml deleted file mode 100644 index bce9a80d8..000000000 --- a/proposal/myrmidon/src/test/org/apache/tools/ant/test/basic-test.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/if-unless-test.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/if-unless-test.xml deleted file mode 100644 index 97e8a63aa..000000000 --- a/proposal/myrmidon/src/test/org/apache/tools/ant/test/if-unless-test.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/proposal/myrmidon/src/test/org/apache/tools/ant/test/subdir/build.xml b/proposal/myrmidon/src/test/org/apache/tools/ant/test/subdir/build.xml deleted file mode 100644 index 317aee134..000000000 --- a/proposal/myrmidon/src/test/org/apache/tools/ant/test/subdir/build.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file