From b3113b77b25a28b2ec5a7f948bbb47de927309b8 Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Wed, 20 Mar 2002 06:42:03 +0000 Subject: [PATCH] some comment cleanup/addition and factored out a test into a standalone assertion git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271916 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/BuildFileTest.java | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/testcases/org/apache/tools/ant/BuildFileTest.java b/src/testcases/org/apache/tools/ant/BuildFileTest.java index 9e507d943..713445bb5 100644 --- a/src/testcases/org/apache/tools/ant/BuildFileTest.java +++ b/src/testcases/org/apache/tools/ant/BuildFileTest.java @@ -203,7 +203,7 @@ public abstract class BuildFileTest extends TestCase { /** * set up to run the named project * - *@param filename name of project file to run + * @param filename name of project file to run */ protected void configureProject(String filename) { logBuffer = new StringBuffer(); @@ -217,8 +217,8 @@ public abstract class BuildFileTest extends TestCase { /** * execute a target we have set up - *@pre configureProject has been called - *@param targetName target to run + * @pre configureProject has been called + * @param targetName target to run */ protected void executeTarget(String targetName) { PrintStream sysOut = System.out; @@ -251,7 +251,11 @@ public abstract class BuildFileTest extends TestCase { protected Project getProject() { return project; } - + + /** + * get the directory of the project + * @return the base dir of the project + */ protected File getProjectDir() { return project.getBaseDir(); } @@ -269,7 +273,9 @@ public abstract class BuildFileTest extends TestCase { executeTarget(target); } catch (org.apache.tools.ant.BuildException ex) { if ((null != msg) && (!ex.getMessage().equals(msg))) { - fail("Should throw BuildException because '" + cause + "' with message '" + msg + "' (actual message '" + ex.getMessage() + "' instead)"); + fail("Should throw BuildException because '" + cause + + "' with message '" + msg + + "' (actual message '" + ex.getMessage() + "' instead)"); } return; } @@ -308,13 +314,22 @@ public abstract class BuildFileTest extends TestCase { protected void expectPropertySet(String target, String property, String value) { executeTarget(target); + assertPropertyEquals(property, value); + } + + /** + * assert that a property equals a value; comparison is case sensitive. + * @param property property name + * @param value expected value + */ + protected void assertPropertyEquals(String property, String value) { String result = project.getProperty(property); assertEquals("property " + property,value,result); } /** - * call a target, verify property is "true" + * call a target, verify named property is "true". * * @param target build file target * @param property property name @@ -346,13 +361,19 @@ public abstract class BuildFileTest extends TestCase { return url; } + /** + * an output stream which saves stuff to our buffer. + */ private class AntOutputStream extends java.io.OutputStream { public void write(int b) { outBuffer.append((char)b); } } - - private class AntTestListener implements BuildListener { + + /** + * our own personal build listener + */ + private class AntTestListener implements BuildListener { /** * Fired before any targets are started. */ @@ -415,8 +436,7 @@ public abstract class BuildFileTest extends TestCase { public void messageLogged(BuildEvent event) { if (event.getPriority() == Project.MSG_INFO || event.getPriority() == Project.MSG_WARN || - event.getPriority() == Project.MSG_ERR) - { + event.getPriority() == Project.MSG_ERR) { logBuffer.append(event.getMessage()); } fullLogBuffer.append(event.getMessage());