Browse Source

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
master
Steve Loughran 23 years ago
parent
commit
b3113b77b2
1 changed files with 30 additions and 10 deletions
  1. +30
    -10
      src/testcases/org/apache/tools/ant/BuildFileTest.java

+ 30
- 10
src/testcases/org/apache/tools/ant/BuildFileTest.java View File

@@ -203,7 +203,7 @@ public abstract class BuildFileTest extends TestCase {
/** /**
* set up to run the named project * 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) { protected void configureProject(String filename) {
logBuffer = new StringBuffer(); logBuffer = new StringBuffer();
@@ -217,8 +217,8 @@ public abstract class BuildFileTest extends TestCase {
/** /**
* execute a target we have set up * 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) { protected void executeTarget(String targetName) {
PrintStream sysOut = System.out; PrintStream sysOut = System.out;
@@ -251,7 +251,11 @@ public abstract class BuildFileTest extends TestCase {
protected Project getProject() { protected Project getProject() {
return project; return project;
} }

/**
* get the directory of the project
* @return the base dir of the project
*/
protected File getProjectDir() { protected File getProjectDir() {
return project.getBaseDir(); return project.getBaseDir();
} }
@@ -269,7 +273,9 @@ public abstract class BuildFileTest extends TestCase {
executeTarget(target); executeTarget(target);
} catch (org.apache.tools.ant.BuildException ex) { } catch (org.apache.tools.ant.BuildException ex) {
if ((null != msg) && (!ex.getMessage().equals(msg))) { 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; return;
} }
@@ -308,13 +314,22 @@ public abstract class BuildFileTest extends TestCase {


protected void expectPropertySet(String target, String property, String value) { protected void expectPropertySet(String target, String property, String value) {
executeTarget(target); 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); String result = project.getProperty(property);
assertEquals("property " + property,value,result); 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 target build file target
* @param property property name * @param property property name
@@ -346,13 +361,19 @@ public abstract class BuildFileTest extends TestCase {
return url; return url;
} }


/**
* an output stream which saves stuff to our buffer.
*/
private class AntOutputStream extends java.io.OutputStream { private class AntOutputStream extends java.io.OutputStream {
public void write(int b) { public void write(int b) {
outBuffer.append((char)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. * Fired before any targets are started.
*/ */
@@ -415,8 +436,7 @@ public abstract class BuildFileTest extends TestCase {
public void messageLogged(BuildEvent event) { public void messageLogged(BuildEvent event) {
if (event.getPriority() == Project.MSG_INFO || if (event.getPriority() == Project.MSG_INFO ||
event.getPriority() == Project.MSG_WARN || event.getPriority() == Project.MSG_WARN ||
event.getPriority() == Project.MSG_ERR)
{
event.getPriority() == Project.MSG_ERR) {
logBuffer.append(event.getMessage()); logBuffer.append(event.getMessage());
} }
fullLogBuffer.append(event.getMessage()); fullLogBuffer.append(event.getMessage());


Loading…
Cancel
Save