[testng] 01/01: New upstream version 6.8.20
Eugene Zhukov
eugene-guest at moszumanska.debian.org
Tue Feb 3 14:01:04 UTC 2015
This is an automated email from the git hooks/post-receive script.
eugene-guest pushed a commit to branch master
in repository testng.
commit 1c54ed703e0a2d25fd696508179e7ad30cab236d
Author: Eugene Zhukov <jevgeni.zh at gmail.com>
Date: Tue Feb 3 13:27:14 2015 +0000
New upstream version 6.8.20
---
debian/changelog | 6 ++++++
pom.xml | 5 +++--
src/main/java/org/testng/Reporter.java | 29 +++++++++++++++++++++++++++-
src/test/java/test/reports/ReporterTest.java | 20 +++++++++++++++++++
4 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index ed8801d..4b7690d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+testng (6.8.20-1) experimental; urgency=medium
+
+ * New upstream release
+
+ -- Eugene Zhukov <jevgeni.zh at gmail.com> Tue, 03 Feb 2015 13:25:20 +0000
+
testng (6.8.17-1) experimental; urgency=medium
* New upstream release
diff --git a/pom.xml b/pom.xml
index 7c26d90..adbaa17 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,3 +1,4 @@
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- Refer to the file ./build-with-maven for instruction on how to use this pom.xml -->
@@ -7,7 +8,7 @@
<artifactId>testng</artifactId>
<packaging>jar</packaging>
<name>TestNG</name>
- <version>6.8.17</version>
+ <version>6.8.20</version>
<description>TestNG is a testing framework.</description>
<url>http://testng.org</url>
@@ -44,7 +45,7 @@
<repositories>
<repository>
- <id>snapshot-repository</id>
+ <id>nexus-snapshot-repository</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
diff --git a/src/main/java/org/testng/Reporter.java b/src/main/java/org/testng/Reporter.java
index b2f30eb..0deba10 100755
--- a/src/main/java/org/testng/Reporter.java
+++ b/src/main/java/org/testng/Reporter.java
@@ -1,5 +1,6 @@
package org.testng;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Vector;
@@ -19,7 +20,7 @@ import org.testng.util.Strings;
* The reporter keeps a combined output of strings (in m_output) and also
* a record of which method output which line. In order to do this, callers
* specify what the current method is with setCurrentTestResult() and the
- * Reporter maintaing a mapping of each test result with a list of integers.
+ * Reporter maintains a mapping of each test result with a list of integers.
* These integers are indices in the combined output (avoids duplicating
* the output).
*
@@ -41,6 +42,9 @@ public class Reporter {
private static Map<Integer, List<Integer>> m_methodOutputMap = Maps.newHashMap();
private static boolean m_escapeHtml = false;
+ //This variable is responsible for persisting all output that is yet to be associated with any
+ //valid TestResult objects.
+ private static ThreadLocal<List<String>> m_orphanedOutput = new InheritableThreadLocal<List<String>>();
public static void setCurrentTestResult(ITestResult m) {
m_currentTestResult.set(m);
@@ -71,13 +75,32 @@ public class Reporter {
s = Strings.escapeHtml(s);
}
+ if (m == null) {
+ //Persist the output temporarily into a Threadlocal String list.
+ if (m_orphanedOutput.get() == null) {
+ m_orphanedOutput.set(new ArrayList<String>());
+ }
+ m_orphanedOutput.get().add(s);
+ return;
+ }
+
// synchronization needed to ensure the line number and m_output are updated atomically
int n = getOutput().size();
+
List<Integer> lines = m_methodOutputMap.get(m.hashCode());
if (lines == null) {
lines = Lists.newArrayList();
m_methodOutputMap.put(m.hashCode(), lines);
}
+
+ // Check if there was already some orphaned output for the current thread.
+ if (m_orphanedOutput.get() != null) {
+ n = n + m_orphanedOutput.get().size();
+ getOutput().addAll(m_orphanedOutput.get());
+ // Since we have already added all of the orphaned output to the current
+ // TestResult, lets clear it off
+ m_orphanedOutput.remove();
+ }
lines.add(n);
getOutput().add(s);
}
@@ -145,6 +168,10 @@ public class Reporter {
public static synchronized List<String> getOutput(ITestResult tr) {
List<String> result = Lists.newArrayList();
+ if (tr == null) {
+ //guard against a possible NPE in scenarios wherein the test result object itself could be a null value.
+ return result;
+ }
List<Integer> lines = m_methodOutputMap.get(tr.hashCode());
if (lines != null) {
for (Integer n : lines) {
diff --git a/src/test/java/test/reports/ReporterTest.java b/src/test/java/test/reports/ReporterTest.java
new file mode 100644
index 0000000..4a58143
--- /dev/null
+++ b/src/test/java/test/reports/ReporterTest.java
@@ -0,0 +1,20 @@
+package test.reports;
+
+import org.testng.*;
+import org.testng.annotations.Listeners;
+import org.testng.annotations.Test;
+
+import java.util.Set;
+
+ at Listeners(ReporterTest.class)
+public class ReporterTest extends TestListenerAdapter {
+ @Override public void onStart (ITestContext testContext) {
+ Reporter.log ("foo");
+ }
+ @Test
+ public void testMethod() {
+ Reporter.log ("bar"); // This line is required. Else the log that was triggered from onStart() would never be
+ // persisted at all.
+ Assert.assertTrue (Reporter.getOutput ().size () == 2);
+ }
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/testng.git
More information about the pkg-java-commits
mailing list