Permalink
Browse files

Added DumpData

  • Loading branch information...
Bela Ban
Bela Ban committed Feb 9, 2012
1 parent 21ccc5a commit b14c275f78c4822ee68a8a2cf377e857660f9839
View
@@ -0,0 +1,8 @@
+
+# Author: Bela Ban
+
+#!/bin/bash
+
+JG=$HOME/JGroups
+
+jgroups.sh org.jgroups.util.DumpData $*
@@ -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 <tests.data>");
+ return;
+ }
+
+ File file=new File(args[0]);
+ if(!file.exists()) {
+ System.err.println(file + " not found");
+ return;
+ }
+ List<JUnitXMLReporter.TestCase> test_cases=new ArrayList<JUnitXMLReporter.TestCase>();
+ 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"));
+ }
+}
@@ -392,7 +392,7 @@ protected static String escape(String message) {
return message != null? message.replaceAll("<", LT).replaceAll(">", GT) : message;
}
- protected static long getTotalTime(Collection<TestCase> results) {
+ public static long getTotalTime(Collection<TestCase> results) {
long start=0, stop=0;
for(TestCase result: results) {
if(result == null)
@@ -413,7 +413,7 @@ protected static long getTotalTime(Collection<TestCase> results) {
return stop - start;
}
- protected static int getFailures(Collection<TestCase> results) {
+ public static int getFailures(Collection<TestCase> results) {
int retval=0;
for(TestCase result: results) {
if(result != null && result.status == ITestResult.FAILURE)
@@ -422,7 +422,7 @@ protected static int getFailures(Collection<TestCase> results) {
return retval;
}
- protected static int getErrors(Collection<TestCase> results) {
+ public static int getErrors(Collection<TestCase> results) {
int retval=0;
for(TestCase result: results) {
if(result != null && result.status != ITestResult.SUCCESS
@@ -433,7 +433,7 @@ protected static int getErrors(Collection<TestCase> results) {
return retval;
}
- protected static int getSkips(Collection<TestCase> results) {
+ public static int getSkips(Collection<TestCase> 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 @@ public static void main(String[] args) throws IOException {
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;
@@ -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 @@
static final int SIZE=1000; // bytes
static final int NUM_MSGS=10000;
- @BeforeMethod
- void before() {
- throw new NullPointerException("booom");
- }
@AfterMethod
void tearDown() throws Exception {

0 comments on commit b14c275

Please sign in to comment.