Skip to content

Commit

Permalink
Added DumpData
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Feb 9, 2012
1 parent 21ccc5a commit b14c275
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 11 deletions.
8 changes: 8 additions & 0 deletions bin/dumpdata.sh
@@ -0,0 +1,8 @@

# Author: Bela Ban

#!/bin/bash

JG=$HOME/JGroups

jgroups.sh org.jgroups.util.DumpData $*
63 changes: 63 additions & 0 deletions 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 <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"));
}
}
12 changes: 6 additions & 6 deletions src/org/jgroups/util/JUnitXMLReporter.java
Expand Up @@ -392,7 +392,7 @@ protected static String escape(String message) {
return message != null? message.replaceAll("<", LT).replaceAll(">", GT) : 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; long start=0, stop=0;
for(TestCase result: results) { for(TestCase result: results) {
if(result == null) if(result == null)
Expand All @@ -413,7 +413,7 @@ protected static long getTotalTime(Collection<TestCase> results) {
return stop - start; return stop - start;
} }


protected static int getFailures(Collection<TestCase> results) { public static int getFailures(Collection<TestCase> results) {
int retval=0; int retval=0;
for(TestCase result: results) { for(TestCase result: results) {
if(result != null && result.status == ITestResult.FAILURE) if(result != null && result.status == ITestResult.FAILURE)
Expand All @@ -422,7 +422,7 @@ protected static int getFailures(Collection<TestCase> results) {
return retval; return retval;
} }


protected static int getErrors(Collection<TestCase> results) { public static int getErrors(Collection<TestCase> results) {
int retval=0; int retval=0;
for(TestCase result: results) { for(TestCase result: results) {
if(result != null && result.status != ITestResult.SUCCESS if(result != null && result.status != ITestResult.SUCCESS
Expand All @@ -433,7 +433,7 @@ protected static int getErrors(Collection<TestCase> results) {
return retval; return retval;
} }


protected static int getSkips(Collection<TestCase> results) { public static int getSkips(Collection<TestCase> results) {
int retval=0; int retval=0;
for(TestCase result: results) { for(TestCase result: results) {
if(result != null && result.status == ITestResult.SKIP) if(result != null && result.status == ITestResult.SKIP)
Expand Down Expand Up @@ -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 int status;
protected String classname; protected String classname;
protected String name; protected String name;
Expand All @@ -558,7 +558,7 @@ protected static class TestCase implements Streamable {
public TestCase() { // needed for externalization 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.status=status;
this.classname=classname; this.classname=classname;
this.name=name; this.name=name;
Expand Down
5 changes: 0 additions & 5 deletions tests/junit-functional/org/jgroups/tests/UNICAST_Test.java
Expand Up @@ -11,7 +11,6 @@
import org.jgroups.util.Util; import org.jgroups.util.Util;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;


Expand All @@ -30,10 +29,6 @@ public class UNICAST_Test {
static final int SIZE=1000; // bytes static final int SIZE=1000; // bytes
static final int NUM_MSGS=10000; static final int NUM_MSGS=10000;


@BeforeMethod
void before() {
throw new NullPointerException("booom");
}


@AfterMethod @AfterMethod
void tearDown() throws Exception { void tearDown() throws Exception {
Expand Down

0 comments on commit b14c275

Please sign in to comment.