/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
*/
/**
* This class is our replacement for the test results that TestNG generates.
* It prints out test to the console as they happen.
*/
// This is used to communicate with build.xml. So that even when a test
// fails, we can do the coverage report before failing the build.
public static final String TEST_PROGRESS_MEMORY_GCS = "gcs"; // Hidden for now, since it's not useful to most developers
private boolean doProgressNone = false;
private boolean doProgressTime = true;
private boolean doProgressTestCount = true;
private boolean doProgressMemory = false;
private boolean doProgressMemoryGcs = false;
private boolean doProgressRestarts = true;
private boolean doProgressThreadCount = false;
private boolean doProgressThreadChanges = false;
private void initializeProgressVars() {
return;
}
// Accept the defaults
doProgressNone = true;
doProgressTime = false;
doProgressTestCount = false;
doProgressMemory = false;
doProgressMemoryGcs = false;
doProgressRestarts = false;
doProgressThreadCount = false;
doProgressThreadChanges = false;
doProgressNone = false;
doProgressTime = true;
doProgressTestCount = true;
doProgressMemory = true;
doProgressMemoryGcs = true;
doProgressRestarts = true;
doProgressThreadCount = true;
doProgressThreadChanges = true;
} else {
doProgressNone = false;
// If we were asked to do the defaults, then restore anything that's on by default
doProgressTime = true;
doProgressTestCount = true;
doProgressRestarts = true;
}
}
}
}
private static final String DIVIDER_LINE = "-------------------------------------------------------------------------------" + EOL;
super.onStart(testContext);
// Delete the previous report if it's there.
}
}
// Signal 'ant' that all of the tests passed by removing this
// special file.
{
}
}
try {
} catch (FileNotFoundException e) {
originalSystemErr.println("Could not open " + reportFile + " for writing. Will write the unit test report to the console instead.");
}
{
}
originalSystemErr.println("There were no explicit test failures, but some tests were skipped (possibly due to errors in @Before* or @After* methods).");
}
}
}
// HACK: print out status for the last test object
int numFailures = 1;
// Peek ahead to see if we had multiple failures for the same method
// In which case, we list it once with a count of the failures.
numFailures++;
i++;
}
if (numFailures > 1) {
}
}
originalSystemErr.println("Include the ant option '-Dtest.failures=true' to rerun only the failed tests.");
} else {
}
originalSystemErr.println("Test classes run interleaved: " + _classesWithTestsRunInterleaved.size());
// Try to hard to reclaim as much memory as possible.
runGc();
if (doProgressMemory) {
}
long totalRestartMs = 0;
for (long restartMs: systemRestartTimes) {
}
double averageRestartSec = 0;
}
if (doProgressThreadChanges) {
}
"were run out of order (i.e. interleaved with other classes). Either " +
"a class doesn't have the sequential=true annotation, which should " +
"have been reported already or there has been a regression with TestNG.");
}
}
super.onTestStart(tr);
}
// Clear when a test finishes instead before the next one starts
// so that we get the output generated by any @BeforeClass method etc.
}
super.onTestSuccess(tr);
}
super.onTestFailure(tr);
}
}
{
}
}
public static void pauseOnFailure() {
try
{
}
catch (Exception e)
{
"file. Pausing test execution indefinitely.");
"JVM when you're done investigating the problem.");
}
{
try
{
} catch (Exception e) {}
}
"case execution.");
}
{
}
super.onConfigurationFailure(tr);
}
originalSystemErr.print(EOL + EOL + EOL + " C O N F I G U R A T I O N F A I L U R E ! ! !" + EOL + EOL);
}
int lowestOpenDSFrame;
break;
}
}
for (int i = 0; i <= lowestOpenDSFrame; i++) {
}
if (t != null) {
if (cause instanceof InvocationTargetException) {
}
}
}
for (int i = 0; i < indent; i++) {
}
}
super.onTestSkipped(tr);
}
}
// Read the comments in DirectoryServerTestCase to understand what's
// going on here.
if (testInstance instanceof DirectoryServerTestCase) {
// This can eat up a bunch of memory for tests that are expected to throw
} else {
// When the test finishes later on, we might not have everything
// that we need to print the result (e.g. the Schema for an Entry
// or DN), so go ahead and convert it to a String now.
}
} else {
// We already warned about it.
}
}
}
if (parameters == null) {
return null;
}
}
return strParams;
}
// Only warn once per class.
return;
}
"from DirectoryServerTestCase.";
throw new RuntimeException(errorMessage);
}
if (classWithTestAnnotation == null) {
"All test classes must have a @Test annotation, and this annotation must have " +
"sequential=true set to ensure that tests for a single class are run together.";
throw new RuntimeException(errorMessage);
}
if (!testAnnotation.sequential()) {
// Give an error message that is as specific as possible.
(classWithTestAnnotation.equals(testClass) ? " " : (", which is declared by class " + classWithTestAnnotation.getName() + ", ")) +
"must include sequential=true to ensure that tests for a single class are run together.";
throw new RuntimeException(errorMessage);
}
}
private final IdentityHashMap<Object,Object> _previousTestObjects = new IdentityHashMap<Object,Object>();
// This will almost always have a single element. If it doesn't, just
// skip it.
return;
}
// We're running another test on the same test object. Everything is fine.
if (_lastTestObject == testInstance) {
return;
}
// Otherwise, we're running a new test, so save the old one.
if (_lastTestObject != null) {
}
// Output progress info since we're running a new class
// And make sure we don't have a test object that we already ran tests with.
}
}
// Only warn once per method.
return;
}
"However, TestNG assumes it is a test method because it's a public method " +
"in a class with a class-level @Test annotation. You can remove this warning by either " +
"marking the method with @Test or by making it non-public.";
}
}
// Return the class in cls's inheritence hierarchy that has the @Test
// annotation defined.
return cls;
} else {
}
}
return null;
}
private boolean statusHeaderPrinted = false;
private synchronized void printStatusHeaderOnce() {
if (statusHeaderPrinted) {
return;
}
statusHeaderPrinted = true;
if (doProgressNone) {
return;
}
if (doProgressTime) {
}
if (doProgressTestCount) {
originalSystemErr.println(" Test count status: {# test classes # test methods # test method invocations # test failures}.");
}
if (doProgressMemory) {
}
if (doProgressMemoryGcs) {
}
if (doProgressThreadCount) {
}
if (doProgressRestarts) {
}
if (doProgressThreadChanges) {
originalSystemErr.println(" Thread change status: +/- thread name for new or finished threads since last status");
}
}
if (doProgressNone) {
return;
}
if (doProgressTime) {
(durationSec / 60),
(durationSec % 60),
(durationLastMs / 1000.0));
}
if (doProgressTestCount) {
}
if (doProgressMemory) {
memDelta * perMegaByte);
if (doProgressMemoryGcs) {
gcs,
gcDuration / 1000.0);
}
}
if (doProgressThreadCount) {
}
if (doProgressRestarts) {
}
if (finishedTestObject == null) {
} else {
}
if (doProgressThreadChanges) {
if (!newThreads.isEmpty()) {
}
}
}
}
}
private int runGc() {
int numGcs;
long curMem = usedMemory();
curMem = usedMemory();
}
return numGcs;
}
}
for (int i = 0; i < numThreads; i++) {
}
}
return activeThreads;
}
/**
* Removes toRemove from base. If there are duplicate items in base, then
* only one is removed for each item in toRemove.
*
* @return a new List with base with toRemove items removed from it
*/
}
return diff;
}
}
private long usedMemory() {
}
private final LinkedHashMap<IClass, TestClassResults> _classResults = new LinkedHashMap<IClass, TestClassResults>();
}
return results;
}
}
return timingOutput;
}
private int countTestMethods() {
int count = 0;
}
return count;
}
int count = 0;
}
return count;
}
private int countTotalInvocations() {
int count = 0;
}
return count;
}
}
return allResults;
}
}
}
}
return -1;
return 1;
} else {
return 0;
}
}
});
return allMethods;
}
return -1;
return 1;
} else {
return 0;
}
}
});
return allClasses;
}
{"<<invalid>>", "Success", "Failure", "Skip", "Success Percentage Failure"};
/**
*
*/
private static class TestClassResults {
private final LinkedHashMap<ITestNGMethod, TestMethodResults> _methods = new LinkedHashMap<ITestNGMethod, TestMethodResults>();
// Indexed by SUCCESS, FAILURE, SKIP, SUCCESS_PERCENTAGE_FAILURE
}
status = 0;
}
_resultCounts[status]++;
}
}
return results;
}
}
}
}
}
int getTotalInvocations() {
return _totalInvocations;
}
long getTotalDurationMs() {
return _totalDurationMs;
}
}
/**
*
*/
private static class TestMethodResults {
// Indexed by SUCCESS, FAILURE, SKIP, SUCCESS_PERCENTAGE_FAILURE
}
status = 0;
}
_resultCounts[status]++;
}
if (includeClassName) {
}
}
}
}
}