/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Runs javadoc and then runs regression tests on the resulting output.
* This class currently contains three tests:
* <ul>
* <li> String search: Reads each file, complete with newlines,
* into a string. Lets you search for strings that contain
* newlines. String matching is case-sensitive.
* You can run javadoc multiple times with different arguments,
* generating output into different destination directories, and
* then perform a different array of tests on each one.
* To do this, the run method accepts a test array for testing
* that a string is found, and a negated test array for testing
* that a string is not found.
* <li> Run diffs: Iterate through the list of given file pairs
* and diff the pairs.
* <li> Check exit code: Check the exit code of Javadoc and
* record whether the test passed or failed.
* </ul>
*
* @author Doug Kramer
* @author Jamie Ho
* @since 1.4.2
*/
public abstract class JavadocTester {
/**
* Use this as the file name in the test array when you want to search
* for a string in the error output.
*/
/**
* Use this as the file name in the test array when you want to search
* for a string in the notice output.
*/
/**
* Use this as the file name in the test array when you want to search
* for a string in the warning output.
*/
/**
* Use this as the file name in the test array when you want to search
* for a string in standard output.
*/
/**
* The default doclet.
*/
/**
* The writer to write error messages.
*/
/**
* The writer to write notices.
*/
/**
* The writer to write warnings.
*/
/**
* The buffer of warning output..
*/
/**
* The current subtest number.
*/
/**
* The number of subtests passed.
*/
/**
* The current run of javadoc
*/
/**
* Whether or not to match newlines exactly.
* Set this value to false if the match strings
* contain text from javadoc comments containing
* non-platform newlines.
*/
protected boolean exactNewlineMatch = true;
/**
* Construct a JavadocTester.
*/
public JavadocTester() {
}
/**
* Return the bug id.
* @return the bug id
*/
/**
* Return the name of the bug.
* @return the name of the bug
*/
/**
* Execute the tests.
*
* @param tester the tester to execute
* @param args the arguments to pass to Javadoc
* @param testArray the array of tests
* @param negatedTestArray the array of negated tests
* @return the return code for the execution of Javadoc
*/
return returnCode;
}
/**
* Execute Javadoc using the default doclet.
*
* @param args the arguments to pass to Javadoc
* @return the return code from the execution of Javadoc
*/
}
/**
* Execute Javadoc.
*
* @param docletClass the doclet being tested.
* @param args the arguments to pass to Javadoc
* @return the return code from the execution of Javadoc
*/
if (javadocRunNum == 1) {
} else {
+ javadocRunNum + ")...");
}
getBugName(),
new PrintWriter(errors, true),
new PrintWriter(warnings, true),
new PrintWriter(notices, true),
getClass().getClassLoader(),
args);
return returnCode;
}
/**
* Create new string writer buffers
*/
private void initOutputBuffers() {
errors = new StringWriter();
notices = new StringWriter();
warnings = new StringWriter();
}
/**
* Run array of tests on the resulting HTML.
* This method accepts a testArray for testing that a string is found
* and a negatedTestArray for testing that a string is not found.
*
* @param testArray the array of tests
* @param negatedTestArray the array of negated tests
*/
runTestsOnHTML(testArray, false);
runTestsOnHTML(negatedTestArray, true);
}
/**
* Run the array of tests on the resulting HTML.
*
* @param testArray the array of tests
* @param isNegated true if test is negated; false otherwise
*/
numTestsRun++;
// Get string to find
// Read contents of file into a string
try {
} catch (Error e) {
if (isNegated) {
numTestsPassed += 1;
continue;
}
throw e;
}
// Find string in file's contents
numTestsPassed += 1;
} else {
+ "for bug " + getBugId()
+ "when searching for:" + "\n"
}
}
}
/**
* Iterate through the list of given file pairs and diff each file.
*
* @param filePairs the pairs of files to diff.
* @throws an Error is thrown if any differences are found between
* file pairs.
*/
}
/**
* Iterate through the list of given file pairs and diff each file.
*
* @param filePairs the pairs of files to diff.
* @param throwErrorIFNoMatch flag to indicate whether or not to throw
* an error if the files do not match.
*
* @throws an Error is thrown if any differences are found between
* file pairs and throwErrorIFNoMatch is true.
*/
}
}
/**
* Check the exit code of Javadoc and record whether the test passed
* or failed.
*
* @param expectedExitCode The exit code that is required for the test
* to pass.
* @param actualExitCode The actual exit code from the previous run of
* Javadoc.
*/
numTestsRun++;
if (expectedExitCode == actualExitCode) {
} else {
}
}
/**
* Print a summary of the test results.
*/
protected void printSummary() {
// Test passed
+ " subtests passed");
} else {
// Test failed
+ " of " + (numTestsRun)
+ " subtests failed for bug " + getBugId()
}
}
/**
* Print the output stored in the buffers.
*/
protected void printJavadocOutput() {
}
/**
* Read the file and return it as a string.
*
* @param fileName the name of the file to read
* @return the file in string format
*/
return getErrorOutput();
return getNoticeOutput();
return getWarningOutput();
return getStandardOutput();
}
try {
}
// Create an array of characters the size of the file
// Read the characters into the allChars array
// Convert to a string
return allCharsString;
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
/**
* Compare the two given files.
*
* @param file1 the first file to compare.
* @param file2 the second file to compare.
* @param throwErrorIFNoMatch flag to indicate whether or not to throw
* an error if the files do not match.
* @return true if the files are the same and false otherwise.
*/
numTestsRun++;
return true;
} else if (throwErrorIFNoMatch) {
} else {
return false;
}
}
/**
* Search for the string in the given file and return true
* if the string was found.
* If exactNewlineMatch is false, newlines will be normalized
* before the comparison.
*
* @param fileString the contents of the file to search through
* @param stringToFind the string to search for
* @return true if the string was found
*/
if (exactNewlineMatch) {
} else {
}
}
/**
* Return the standard output.
* @return the standard output
*/
return standardOut.toString();
}
/**
* Return the error output.
* @return the error output
*/
}
/**
* Return the notice output.
* @return the notice output
*/
}
/**
* Return the warning output.
* @return the warning output
*/
}
/**
* A utility to copy a directory from one place to another.
* We may possibly want to move this to our doclet toolkit in
* the near future and maintain it from there.
*
* @param targetDir the directory to copy.
* @param destDir the destination to copy the directory to.
*/
return;
}
try {
if (! destDirParentObj.exists()) {
}
if (! destDirObj.exists()) {
destDirObj.mkdir();
}
} else if(srcFile.isDirectory()) {
}
}
} catch (IOException exc) {
}
}
/**
* Copy source file to destination file.
*
* @throws SecurityException
* @throws IOException
*/
throws IOException {
byte[] bytearr = new byte[512];
int len = 0;
try {
}
} catch (FileNotFoundException exc) {
} catch (SecurityException exc) {
} finally {
}
}
}