Browse Source

Adding javadocs for the main methods that testcases are likely to call

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271255 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 23 years ago
parent
commit
ab27c9f4e1
1 changed files with 67 additions and 0 deletions
  1. +67
    -0
      src/testcases/org/apache/tools/ant/BuildFileTest.java

+ 67
- 0
src/testcases/org/apache/tools/ant/BuildFileTest.java View File

@@ -79,10 +79,21 @@ public abstract class BuildFileTest extends TestCase {
private StringBuffer errBuffer; private StringBuffer errBuffer;
private BuildException buildException; private BuildException buildException;
/**
* Constructor for the BuildFileTest object
*
*@param name string to pass up to TestCase constructor
*/
public BuildFileTest(String name) { public BuildFileTest(String name) {
super(name); super(name);
} }
/**
* run a target, expect for any build exception
*
*@param target target to run
*@param cause information string to reader of report
*/
protected void expectBuildException(String target, String cause) { protected void expectBuildException(String target, String cause) {
expectSpecificBuildException(target, cause, null); expectSpecificBuildException(target, cause, null);
} }
@@ -97,6 +108,13 @@ public abstract class BuildFileTest extends TestCase {
assertEquals(log, realLog); assertEquals(log, realLog);
} }


/**
* Gets the log the BuildFileTest object.
* only valid if configureProject() has
* been called.
* @pre logBuffer!=null
* @return The log value
*/
protected String getLog() { protected String getLog() {
return logBuffer.toString(); return logBuffer.toString();
} }
@@ -111,16 +129,38 @@ public abstract class BuildFileTest extends TestCase {
assertEquals(log, realLog); assertEquals(log, realLog);
} }


/**
* Gets the log the BuildFileTest object.
* only valid if configureProject() has
* been called.
* @pre fullLogBuffer!=null
* @return The log value
*/
protected String getFullLog() { protected String getFullLog() {
return fullLogBuffer.toString(); return fullLogBuffer.toString();
} }


/**
* execute the target, verify output matches expectations
*
*@param target target to execute
*@param output output to look for
*/
protected void expectOutput(String target, String output) { protected void expectOutput(String target, String output) {
executeTarget(target); executeTarget(target);
String realOutput = getOutput(); String realOutput = getOutput();
assertEquals(output, realOutput); assertEquals(output, realOutput);
} }


/**
* execute the target, verify output matches expectations
* and that we got the named error at the end
*@param target target to execute
*@param output output to look for
*@param error Description of Parameter
*/
protected void expectOutputAndError(String target, String output, String error) { protected void expectOutputAndError(String target, String output, String error) {
executeTarget(target); executeTarget(target);
String realOutput = getOutput(); String realOutput = getOutput();
@@ -160,6 +200,11 @@ public abstract class BuildFileTest extends TestCase {
return cleanedBuffer.toString(); return cleanedBuffer.toString();
} }
/**
* set up to run the named project
*
*@param filename name of project file to run
*/
protected void configureProject(String filename) { protected void configureProject(String filename) {
logBuffer = new StringBuffer(); logBuffer = new StringBuffer();
fullLogBuffer = new StringBuffer(); fullLogBuffer = new StringBuffer();
@@ -170,6 +215,11 @@ public abstract class BuildFileTest extends TestCase {
ProjectHelper.configureProject(project, new File(filename)); ProjectHelper.configureProject(project, new File(filename));
} }
/**
* execute a target we have set up
*@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;
PrintStream sysErr = System.err; PrintStream sysErr = System.err;
@@ -197,6 +247,14 @@ public abstract class BuildFileTest extends TestCase {
return project.getBaseDir(); return project.getBaseDir();
} }


/**
* run a target, wait for a build exception
*
*@param target target to run
*@param cause information string to reader of report
*@param msg the message value of the build exception we are waiting for
set to null for any build exception to be valid
*/
protected void expectSpecificBuildException(String target, String cause, String msg) { protected void expectSpecificBuildException(String target, String cause, String msg) {
try { try {
executeTarget(target); executeTarget(target);
@@ -209,6 +267,15 @@ public abstract class BuildFileTest extends TestCase {
fail("Should throw BuildException because: " + cause); fail("Should throw BuildException because: " + cause);
} }
/**
* run a target, expect an exception string
* containing the substring we look for (case sensitive match)
*
*@param target target to run
*@param cause information string to reader of report
*@param msg the message value of the build exception we are waiting for
*@param contains substring of the build exception to look for
*/
protected void expectBuildExceptionContaining(String target, String cause, String contains) { protected void expectBuildExceptionContaining(String target, String cause, String contains) {
try { try {
executeTarget(target); executeTarget(target);


Loading…
Cancel
Save