Browse Source

made all the protected methods public. Because ProjectTest was trying to call protected methods, and rather than selectively open up the methods, I made the whole set of asserts and operations open.

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

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

@@ -18,7 +18,6 @@
package org.apache.tools.ant; package org.apache.tools.ant;


import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.tools.ant.Project;
import java.io.File; import java.io.File;
import java.io.PrintStream; import java.io.PrintStream;
import java.net.URL; import java.net.URL;
@@ -79,7 +78,7 @@ public abstract class BuildFileTest extends TestCase {
* @param target target to run * @param target target to run
* @param cause information string to reader of report * @param cause information string to reader of report
*/ */
protected void expectBuildException(String target, String cause) {
public void expectBuildException(String target, String cause) {
expectSpecificBuildException(target, cause, null); expectSpecificBuildException(target, cause, null);
} }


@@ -87,7 +86,7 @@ public abstract class BuildFileTest extends TestCase {
* Assert that only the given message has been logged with a * Assert that only the given message has been logged with a
* priority <= INFO when running the given target. * priority <= INFO when running the given target.
*/ */
protected void expectLog(String target, String log) {
public void expectLog(String target, String log) {
executeTarget(target); executeTarget(target);
String realLog = getLog(); String realLog = getLog();
assertEquals(log, realLog); assertEquals(log, realLog);
@@ -96,7 +95,7 @@ public abstract class BuildFileTest extends TestCase {
/** /**
* Assert that the given substring is in the log messages. * Assert that the given substring is in the log messages.
*/ */
protected void assertLogContaining(String substring) {
public void assertLogContaining(String substring) {
String realLog = getLog(); String realLog = getLog();
assertTrue("expecting log to contain \"" + substring + "\" log was \"" assertTrue("expecting log to contain \"" + substring + "\" log was \""
+ realLog + "\"", + realLog + "\"",
@@ -107,7 +106,7 @@ public abstract class BuildFileTest extends TestCase {
* Assert that the given substring is in the output messages. * Assert that the given substring is in the output messages.
* @since Ant1.7 * @since Ant1.7
*/ */
protected void assertOutputContaining(String substring) {
public void assertOutputContaining(String substring) {
String realOutput = getOutput(); String realOutput = getOutput();
assertTrue("expecting output to contain \"" + substring assertTrue("expecting output to contain \"" + substring
+ "\" output was \"" + realOutput + "\"", + "\" output was \"" + realOutput + "\"",
@@ -118,7 +117,7 @@ public abstract class BuildFileTest extends TestCase {
* Assert that the given message has been logged with a priority * Assert that the given message has been logged with a priority
* <= INFO when running the given target. * <= INFO when running the given target.
*/ */
protected void expectLogContaining(String target, String log) {
public void expectLogContaining(String target, String log) {
executeTarget(target); executeTarget(target);
assertLogContaining(log); assertLogContaining(log);
} }
@@ -130,7 +129,7 @@ public abstract class BuildFileTest extends TestCase {
* @pre logBuffer!=null * @pre logBuffer!=null
* @return The log value * @return The log value
*/ */
protected String getLog() {
public String getLog() {
return logBuffer.toString(); return logBuffer.toString();
} }


@@ -138,7 +137,7 @@ public abstract class BuildFileTest extends TestCase {
* Assert that the given message has been logged with a priority * Assert that the given message has been logged with a priority
* >= VERBOSE when running the given target. * >= VERBOSE when running the given target.
*/ */
protected void expectDebuglog(String target, String log) {
public void expectDebuglog(String target, String log) {
executeTarget(target); executeTarget(target);
String realLog = getFullLog(); String realLog = getFullLog();
assertEquals(log, realLog); assertEquals(log, realLog);
@@ -147,7 +146,7 @@ public abstract class BuildFileTest extends TestCase {
/** /**
* Assert that the given substring is in the log messages. * Assert that the given substring is in the log messages.
*/ */
protected void assertDebuglogContaining(String substring) {
public void assertDebuglogContaining(String substring) {
String realLog = getFullLog(); String realLog = getFullLog();
assertTrue("expecting debug log to contain \"" + substring assertTrue("expecting debug log to contain \"" + substring
+ "\" log was \"" + "\" log was \""
@@ -163,7 +162,7 @@ public abstract class BuildFileTest extends TestCase {
* @pre fullLogBuffer!=null * @pre fullLogBuffer!=null
* @return The log value * @return The log value
*/ */
protected String getFullLog() {
public String getFullLog() {
return fullLogBuffer.toString(); return fullLogBuffer.toString();
} }


@@ -173,7 +172,7 @@ public abstract class BuildFileTest extends TestCase {
* @param target target to execute * @param target target to execute
* @param output output to look for * @param output output to look for
*/ */
protected void expectOutput(String target, String output) {
public void expectOutput(String target, String output) {
executeTarget(target); executeTarget(target);
String realOutput = getOutput(); String realOutput = getOutput();
assertEquals(output, realOutput.trim()); assertEquals(output, realOutput.trim());
@@ -187,7 +186,7 @@ public abstract class BuildFileTest extends TestCase {
* @param output output to look for * @param output output to look for
* @param error Description of Parameter * @param error Description of Parameter
*/ */
protected void expectOutputAndError(String target, String output, String error) {
public void expectOutputAndError(String target, String output, String error) {
executeTarget(target); executeTarget(target);
String realOutput = getOutput(); String realOutput = getOutput();
assertEquals(output, realOutput); assertEquals(output, realOutput);
@@ -195,15 +194,15 @@ public abstract class BuildFileTest extends TestCase {
assertEquals(error, realError); assertEquals(error, realError);
} }


protected String getOutput() {
public String getOutput() {
return cleanBuffer(outBuffer); return cleanBuffer(outBuffer);
} }


protected String getError() {
public String getError() {
return cleanBuffer(errBuffer); return cleanBuffer(errBuffer);
} }


protected BuildException getBuildException() {
public BuildException getBuildException() {
return buildException; return buildException;
} }


@@ -231,7 +230,7 @@ public abstract class BuildFileTest extends TestCase {
* *
* @param filename name of project file to run * @param filename name of project file to run
*/ */
protected void configureProject(String filename) throws BuildException {
public void configureProject(String filename) throws BuildException {
configureProject(filename, Project.MSG_DEBUG); configureProject(filename, Project.MSG_DEBUG);
} }


@@ -240,7 +239,7 @@ public abstract class BuildFileTest extends TestCase {
* *
* @param filename name of project file to run * @param filename name of project file to run
*/ */
protected void configureProject(String filename, int logLevel)
public void configureProject(String filename, int logLevel)
throws BuildException { throws BuildException {
logBuffer = new StringBuffer(); logBuffer = new StringBuffer();
fullLogBuffer = new StringBuffer(); fullLogBuffer = new StringBuffer();
@@ -258,7 +257,7 @@ public abstract class BuildFileTest extends TestCase {
* @pre configureProject has been called * @pre configureProject has been called
* @param targetName target to run * @param targetName target to run
*/ */
protected void executeTarget(String targetName) {
public void executeTarget(String targetName) {
PrintStream sysOut = System.out; PrintStream sysOut = System.out;
PrintStream sysErr = System.err; PrintStream sysErr = System.err;
try { try {
@@ -286,7 +285,7 @@ public abstract class BuildFileTest extends TestCase {
* *
* @return the Project instance for this test. * @return the Project instance for this test.
*/ */
protected Project getProject() {
public Project getProject() {
return project; return project;
} }


@@ -295,7 +294,7 @@ public abstract class BuildFileTest extends TestCase {
* *
* @return the base dir of the project * @return the base dir of the project
*/ */
protected File getProjectDir() {
public File getProjectDir() {
return project.getBaseDir(); return project.getBaseDir();
} }


@@ -307,7 +306,7 @@ public abstract class BuildFileTest extends TestCase {
* @param msg the message value of the build exception we are waiting * @param msg the message value of the build exception we are waiting
* for set to null for any build exception to be valid * for set to null for any build exception to be valid
*/ */
protected void expectSpecificBuildException(String target, String cause, String msg) {
public void expectSpecificBuildException(String target, String cause, String msg) {
try { try {
executeTarget(target); executeTarget(target);
} catch (org.apache.tools.ant.BuildException ex) { } catch (org.apache.tools.ant.BuildException ex) {
@@ -330,7 +329,7 @@ public abstract class BuildFileTest extends TestCase {
* @param cause information string to reader of report * @param cause information string to reader of report
* @param contains substring of the build exception to look for * @param contains substring of the build exception to look for
*/ */
protected void expectBuildExceptionContaining(String target, String cause, String contains) {
public void expectBuildExceptionContaining(String target, String cause, String contains) {
try { try {
executeTarget(target); executeTarget(target);
} catch (org.apache.tools.ant.BuildException ex) { } catch (org.apache.tools.ant.BuildException ex) {
@@ -350,7 +349,7 @@ public abstract class BuildFileTest extends TestCase {
* @param property property name * @param property property name
* @param value expected value * @param value expected value
*/ */
protected void expectPropertySet(String target, String property, String value) {
public void expectPropertySet(String target, String property, String value) {
executeTarget(target); executeTarget(target);
assertPropertyEquals(property, value); assertPropertyEquals(property, value);
} }
@@ -361,7 +360,7 @@ public abstract class BuildFileTest extends TestCase {
* @param property property name * @param property property name
* @param value expected value * @param value expected value
*/ */
protected void assertPropertyEquals(String property, String value) {
public 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);
} }
@@ -371,7 +370,7 @@ public abstract class BuildFileTest extends TestCase {
* *
* @param property property name * @param property property name
*/ */
protected void assertPropertySet(String property) {
public void assertPropertySet(String property) {
assertPropertyEquals(property, "true"); assertPropertyEquals(property, "true");
} }


@@ -380,7 +379,7 @@ public abstract class BuildFileTest extends TestCase {
* *
* @param property property name * @param property property name
*/ */
protected void assertPropertyUnset(String property) {
public void assertPropertyUnset(String property) {
assertPropertyEquals(property, null); assertPropertyEquals(property, null);
} }


@@ -390,7 +389,7 @@ public abstract class BuildFileTest extends TestCase {
* @param target build file target * @param target build file target
* @param property property name * @param property property name
*/ */
protected void expectPropertySet(String target, String property) {
public void expectPropertySet(String target, String property) {
expectPropertySet(target, property, "true"); expectPropertySet(target, property, "true");
} }


@@ -400,7 +399,7 @@ public abstract class BuildFileTest extends TestCase {
* @param target build file target * @param target build file target
* @param property property name * @param property property name
*/ */
protected void expectPropertyUnset(String target, String property) {
public void expectPropertyUnset(String target, String property) {
expectPropertySet(target, property, null); expectPropertySet(target, property, null);
} }


@@ -410,9 +409,9 @@ public abstract class BuildFileTest extends TestCase {
* relative to the package name or absolute from the root path. * relative to the package name or absolute from the root path.
* *
* @param resource the resource to retrieve its url. * @param resource the resource to retrieve its url.
* @throws AssertionFailureException if resource is not found.
* @throws junit.framework.AssertionFailedError if the resource is not found.
*/ */
protected URL getResource(String resource){
public URL getResource(String resource){
URL url = getClass().getResource(resource); URL url = getClass().getResource(resource);
assertNotNull("Could not find resource :" + resource, url); assertNotNull("Could not find resource :" + resource, url);
return url; return url;


Loading…
Cancel
Save