From b14c275f78c4822ee68a8a2cf377e857660f9839 Mon Sep 17 00:00:00 2001 From: Bela Ban Date: Thu, 9 Feb 2012 12:18:44 +0100 Subject: [PATCH] Added DumpData --- bin/dumpdata.sh | 8 +++ src/org/jgroups/util/DumpData.java | 63 +++++++++++++++++++ src/org/jgroups/util/JUnitXMLReporter.java | 12 ++-- .../org/jgroups/tests/UNICAST_Test.java | 5 -- 4 files changed, 77 insertions(+), 11 deletions(-) create mode 100755 bin/dumpdata.sh create mode 100644 src/org/jgroups/util/DumpData.java diff --git a/bin/dumpdata.sh b/bin/dumpdata.sh new file mode 100755 index 00000000000..f7ac3720b09 --- /dev/null +++ b/bin/dumpdata.sh @@ -0,0 +1,8 @@ + +# Author: Bela Ban + +#!/bin/bash + +JG=$HOME/JGroups + +jgroups.sh org.jgroups.util.DumpData $* \ No newline at end of file diff --git a/src/org/jgroups/util/DumpData.java b/src/org/jgroups/util/DumpData.java new file mode 100644 index 00000000000..9178f1f6941 --- /dev/null +++ b/src/org/jgroups/util/DumpData.java @@ -0,0 +1,63 @@ +package org.jgroups.util; + +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.List; + +/** + * Dumps the data (tests.data) generated by {@link JUnitXMLReporter} to stdout + * @author Bela Ban + * @since 3.1 + */ +public class DumpData { + public static void main(String[] args) throws FileNotFoundException { + if(args.length == 0) { + System.out.println("DumpData "); + return; + } + + File file=new File(args[0]); + if(!file.exists()) { + System.err.println(file + " not found"); + return; + } + List test_cases=new ArrayList(); + DataInputStream input=new DataInputStream(new FileInputStream(file)); + try { + for(;;) { + JUnitXMLReporter.TestCase test_case=new JUnitXMLReporter.TestCase(); + try { + test_case.readFrom(input); + test_cases.add(test_case); + } + catch(Exception e) { + break; + } + } + } + finally { + Util.close(input); + } + + if(test_cases.isEmpty()) { + System.err.println("No test cases found in " + file); + return; + } + + int num_failures=JUnitXMLReporter.getFailures(test_cases); + int num_skips=JUnitXMLReporter.getSkips(test_cases); + int num_errors=JUnitXMLReporter.getErrors(test_cases); + long total_time=JUnitXMLReporter.getTotalTime(test_cases); + + int cnt=1; + for(JUnitXMLReporter.TestCase test_case: test_cases) { + System.out.println(cnt++ + ": " + test_case); + } + + System.out.println(Util.bold(test_cases.size() + " tests " + num_failures + " failures " + num_errors + + " errors " + num_skips + " skips time=" + (total_time / 1000.0) + "\n")); + } +} diff --git a/src/org/jgroups/util/JUnitXMLReporter.java b/src/org/jgroups/util/JUnitXMLReporter.java index 50d1281f59c..d3aae30e266 100644 --- a/src/org/jgroups/util/JUnitXMLReporter.java +++ b/src/org/jgroups/util/JUnitXMLReporter.java @@ -392,7 +392,7 @@ protected static String escape(String message) { return message != null? message.replaceAll("<", LT).replaceAll(">", GT) : message; } - protected static long getTotalTime(Collection results) { + public static long getTotalTime(Collection results) { long start=0, stop=0; for(TestCase result: results) { if(result == null) @@ -413,7 +413,7 @@ protected static long getTotalTime(Collection results) { return stop - start; } - protected static int getFailures(Collection results) { + public static int getFailures(Collection results) { int retval=0; for(TestCase result: results) { if(result != null && result.status == ITestResult.FAILURE) @@ -422,7 +422,7 @@ protected static int getFailures(Collection results) { return retval; } - protected static int getErrors(Collection results) { + public static int getErrors(Collection results) { int retval=0; for(TestCase result: results) { if(result != null && result.status != ITestResult.SUCCESS @@ -433,7 +433,7 @@ protected static int getErrors(Collection results) { return retval; } - protected static int getSkips(Collection results) { + public static int getSkips(Collection results) { int retval=0; for(TestCase result: results) { if(result != null && result.status == ITestResult.SKIP) @@ -544,7 +544,7 @@ public static void main(String[] args) throws IOException { } - protected static class TestCase implements Streamable { + public static class TestCase implements Streamable { protected int status; protected String classname; protected String name; @@ -558,7 +558,7 @@ protected static class TestCase implements Streamable { public TestCase() { // needed for externalization } - protected TestCase(int status, String classname, String name, long start_time, long stop_time) { + public TestCase(int status, String classname, String name, long start_time, long stop_time) { this.status=status; this.classname=classname; this.name=name; diff --git a/tests/junit-functional/org/jgroups/tests/UNICAST_Test.java b/tests/junit-functional/org/jgroups/tests/UNICAST_Test.java index 265530e29a5..089fddc1c09 100644 --- a/tests/junit-functional/org/jgroups/tests/UNICAST_Test.java +++ b/tests/junit-functional/org/jgroups/tests/UNICAST_Test.java @@ -11,7 +11,6 @@ import org.jgroups.util.Util; import org.testng.Assert; import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -30,10 +29,6 @@ public class UNICAST_Test { static final int SIZE=1000; // bytes static final int NUM_MSGS=10000; - @BeforeMethod - void before() { - throw new NullPointerException("booom"); - } @AfterMethod void tearDown() throws Exception {