org.jgroups.util
Class JUnitXMLReporter

java.lang.Object
  extended by org.jgroups.util.JUnitXMLReporter
All Implemented Interfaces:
org.testng.IConfigurationListener, org.testng.IConfigurationListener2, org.testng.ITestListener, org.testng.ITestNGListener

public class JUnitXMLReporter
extends java.lang.Object
implements org.testng.ITestListener, org.testng.IConfigurationListener2

Listener generating XML output suitable to be processed by JUnitReport. Copied from TestNG (www.testng.org) and modified

Author:
Bela Ban

Nested Class Summary
protected static class JUnitXMLReporter.MyOutput
           
static class JUnitXMLReporter.TestCase
           
 
Field Summary
protected static java.lang.String CDATA
           
protected static java.lang.String GT
           
protected static java.lang.String LT
           
protected  java.io.PrintStream old_stderr
           
protected  java.io.PrintStream old_stdout
           
protected  java.lang.String output_dir
           
static java.lang.InheritableThreadLocal<java.io.PrintStream> stderr
           
protected static java.lang.String STDERR
           
static java.lang.InheritableThreadLocal<java.io.PrintStream> stdout
           
protected static java.lang.String STDOUT
           
protected static java.lang.String SYSTEM_ERR
           
protected static java.lang.String SYSTEM_OUT
           
protected  java.util.concurrent.ConcurrentMap<java.lang.Class<?>,java.io.DataOutputStream> tests
           
protected static java.lang.String TESTS
           
protected static java.lang.String XML_DEF
           
 
Constructor Summary
JUnitXMLReporter()
           
 
Method Summary
protected  void addTest(java.lang.Class<?> clazz, org.testng.ITestResult result)
           
 void beforeConfiguration(org.testng.ITestResult tr)
           
protected static void closeStreams()
           
protected static int copy(java.io.Reader in, java.io.Writer out)
          Copies the contents of in into out
protected static void deleteContents(java.io.File dir)
          Deletes all files and dirs in dir, but not dir itself
protected  void error(java.lang.String msg)
           
protected static java.lang.String escape(java.lang.String message)
           
protected static void generateReport(java.io.Writer out, java.lang.String classname, java.util.List<JUnitXMLReporter.TestCase> results, java.io.Reader stdout, java.io.Reader stderr)
          Generate the XML report from all the test results
protected  void generateReports()
          Generate the XML report from all the test results
static int getErrors(java.util.Collection<JUnitXMLReporter.TestCase> results)
           
static int getFailures(java.util.Collection<JUnitXMLReporter.TestCase> results)
           
protected static java.lang.String getMethodName(org.testng.ITestResult tr)
           
static int getSkips(java.util.Collection<JUnitXMLReporter.TestCase> results)
           
protected static java.lang.String getStatus(JUnitXMLReporter.TestCase tr)
           
static long getTotalTime(java.util.Collection<JUnitXMLReporter.TestCase> results)
           
static void main(java.lang.String[] args)
           
 void onConfigurationFailure(org.testng.ITestResult tr)
           
 void onConfigurationSkip(org.testng.ITestResult tr)
           
 void onConfigurationSuccess(org.testng.ITestResult tr)
           
 void onFinish(org.testng.ITestContext context)
          Invoked after all test classes in this test have been run
 void onStart(org.testng.ITestContext context)
          Invoked at the start of the test, before any of the classes in the test are run
protected  void onTestCompleted(org.testng.ITestResult tr, java.lang.String message, java.io.PrintStream out)
           
 void onTestFailedButWithinSuccessPercentage(org.testng.ITestResult tr)
           
 void onTestFailure(org.testng.ITestResult tr)
          Invoked each time a test method fails
 void onTestSkipped(org.testng.ITestResult tr)
          Invoked each time a test method is skipped
 void onTestStart(org.testng.ITestResult result)
           
 void onTestSuccess(org.testng.ITestResult tr)
          Invoked each time a test method succeeds
protected static void print(java.io.PrintStream out, java.lang.String msg, java.lang.String classname, java.lang.String method_name)
           
protected static java.lang.String printException(java.lang.Throwable ex)
           
protected  void println(java.lang.String msg)
           
protected static void process(java.io.File dir)
           
protected  void setupStreams(org.testng.ITestResult result, boolean printMethodName)
           
protected static java.lang.String writeFailure(java.lang.String type, java.lang.String failure_type, java.lang.String failure_msg, java.lang.String stack_trace)
           
protected static void writeOutput(int type, java.io.Reader in, java.io.Writer out)
           
protected static void writeTestCase(java.io.Writer out, JUnitXMLReporter.TestCase result)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

output_dir

protected java.lang.String output_dir

XML_DEF

protected static final java.lang.String XML_DEF
See Also:
Constant Field Values

CDATA

protected static final java.lang.String CDATA
See Also:
Constant Field Values

LT

protected static final java.lang.String LT
See Also:
Constant Field Values

GT

protected static final java.lang.String GT
See Also:
Constant Field Values

SYSTEM_OUT

protected static final java.lang.String SYSTEM_OUT
See Also:
Constant Field Values

SYSTEM_ERR

protected static final java.lang.String SYSTEM_ERR
See Also:
Constant Field Values

TESTS

protected static final java.lang.String TESTS
See Also:
Constant Field Values

STDOUT

protected static final java.lang.String STDOUT
See Also:
Constant Field Values

STDERR

protected static final java.lang.String STDERR
See Also:
Constant Field Values

old_stdout

protected java.io.PrintStream old_stdout

old_stderr

protected java.io.PrintStream old_stderr

tests

protected final java.util.concurrent.ConcurrentMap<java.lang.Class<?>,java.io.DataOutputStream> tests

stdout

public static final java.lang.InheritableThreadLocal<java.io.PrintStream> stdout

stderr

public static final java.lang.InheritableThreadLocal<java.io.PrintStream> stderr
Constructor Detail

JUnitXMLReporter

public JUnitXMLReporter()
Method Detail

onStart

public void onStart(org.testng.ITestContext context)
Invoked at the start of the test, before any of the classes in the test are run

Specified by:
onStart in interface org.testng.ITestListener

onFinish

public void onFinish(org.testng.ITestContext context)
Invoked after all test classes in this test have been run

Specified by:
onFinish in interface org.testng.ITestListener

onTestStart

public void onTestStart(org.testng.ITestResult result)
Specified by:
onTestStart in interface org.testng.ITestListener

onTestSuccess

public void onTestSuccess(org.testng.ITestResult tr)
Invoked each time a test method succeeds

Specified by:
onTestSuccess in interface org.testng.ITestListener

onTestFailedButWithinSuccessPercentage

public void onTestFailedButWithinSuccessPercentage(org.testng.ITestResult tr)
Specified by:
onTestFailedButWithinSuccessPercentage in interface org.testng.ITestListener

onTestFailure

public void onTestFailure(org.testng.ITestResult tr)
Invoked each time a test method fails

Specified by:
onTestFailure in interface org.testng.ITestListener

onTestSkipped

public void onTestSkipped(org.testng.ITestResult tr)
Invoked each time a test method is skipped

Specified by:
onTestSkipped in interface org.testng.ITestListener

beforeConfiguration

public void beforeConfiguration(org.testng.ITestResult tr)
Specified by:
beforeConfiguration in interface org.testng.IConfigurationListener2

onConfigurationSuccess

public void onConfigurationSuccess(org.testng.ITestResult tr)
Specified by:
onConfigurationSuccess in interface org.testng.IConfigurationListener

onConfigurationFailure

public void onConfigurationFailure(org.testng.ITestResult tr)
Specified by:
onConfigurationFailure in interface org.testng.IConfigurationListener

onConfigurationSkip

public void onConfigurationSkip(org.testng.ITestResult tr)
Specified by:
onConfigurationSkip in interface org.testng.IConfigurationListener

onTestCompleted

protected void onTestCompleted(org.testng.ITestResult tr,
                               java.lang.String message,
                               java.io.PrintStream out)

setupStreams

protected void setupStreams(org.testng.ITestResult result,
                            boolean printMethodName)

closeStreams

protected static void closeStreams()

print

protected static void print(java.io.PrintStream out,
                            java.lang.String msg,
                            java.lang.String classname,
                            java.lang.String method_name)

error

protected void error(java.lang.String msg)

println

protected void println(java.lang.String msg)

addTest

protected void addTest(java.lang.Class<?> clazz,
                       org.testng.ITestResult result)

getMethodName

protected static java.lang.String getMethodName(org.testng.ITestResult tr)

generateReports

protected void generateReports()
                        throws java.io.IOException
Generate the XML report from all the test results

Throws:
java.io.IOException

process

protected static void process(java.io.File dir)
                       throws java.io.IOException
Throws:
java.io.IOException

generateReport

protected static void generateReport(java.io.Writer out,
                                     java.lang.String classname,
                                     java.util.List<JUnitXMLReporter.TestCase> results,
                                     java.io.Reader stdout,
                                     java.io.Reader stderr)
                              throws java.io.IOException
Generate the XML report from all the test results

Throws:
java.io.IOException

writeTestCase

protected static void writeTestCase(java.io.Writer out,
                                    JUnitXMLReporter.TestCase result)
                             throws java.io.IOException
Throws:
java.io.IOException

writeOutput

protected static void writeOutput(int type,
                                  java.io.Reader in,
                                  java.io.Writer out)
                           throws java.io.IOException
Throws:
java.io.IOException

getStatus

protected static java.lang.String getStatus(JUnitXMLReporter.TestCase tr)

writeFailure

protected static java.lang.String writeFailure(java.lang.String type,
                                               java.lang.String failure_type,
                                               java.lang.String failure_msg,
                                               java.lang.String stack_trace)
                                        throws java.io.IOException
Throws:
java.io.IOException

printException

protected static java.lang.String printException(java.lang.Throwable ex)
                                          throws java.io.IOException
Throws:
java.io.IOException

escape

protected static java.lang.String escape(java.lang.String message)

getTotalTime

public static long getTotalTime(java.util.Collection<JUnitXMLReporter.TestCase> results)

getFailures

public static int getFailures(java.util.Collection<JUnitXMLReporter.TestCase> results)

getErrors

public static int getErrors(java.util.Collection<JUnitXMLReporter.TestCase> results)

getSkips

public static int getSkips(java.util.Collection<JUnitXMLReporter.TestCase> results)

deleteContents

protected static void deleteContents(java.io.File dir)
Deletes all files and dirs in dir, but not dir itself


copy

protected static int copy(java.io.Reader in,
                          java.io.Writer out)
Copies the contents of in into out


main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.