From fde01b72bba8887af4d333bea3e2cd5248642d5a Mon Sep 17 00:00:00 2001 From: Krishnan Mahadevan Date: Mon, 5 Jun 2023 17:39:31 +0530 Subject: [PATCH] Minor code clean-ups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Reporter.log() to use LinkedList instead of using “Vector” so that we are a bit more memory efficient. * Deprecated the old SuiteHTMLReporter since its being generated in a “old” folder and we have a new jquery backed newer report. * Removed SuiteHTMLReporter from being generated by default. If a user wants, they can refer to it explicitly as a listener * Deprecated the old EmailableReporter which is not even being generated in favour of EmailableReporter2 --- .../src/main/java/org/testng/Reporter.java | 11 +++++------ testng-core/src/main/java/org/testng/TestNG.java | 2 -- .../java/org/testng/reporters/EmailableReporter.java | 2 ++ .../java/org/testng/reporters/SuiteHTMLReporter.java | 3 +++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/testng-core-api/src/main/java/org/testng/Reporter.java b/testng-core-api/src/main/java/org/testng/Reporter.java index ebe2020b3c..e27356b6db 100644 --- a/testng-core-api/src/main/java/org/testng/Reporter.java +++ b/testng-core-api/src/main/java/org/testng/Reporter.java @@ -1,9 +1,8 @@ package org.testng; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Vector; import org.testng.collections.Lists; import org.testng.collections.Maps; import org.testng.internal.Utils; @@ -32,9 +31,9 @@ public class Reporter { new InheritableThreadLocal<>(); /** All output logged in a sequential order. */ - private static final List m_output = new Vector<>(); + private static final List m_output = new LinkedList<>(); - private static final Map> m_methodOutputMap = Maps.newHashMap(); + private static final Map> m_methodOutputMap = Maps.newConcurrentMap(); private static boolean m_escapeHtml = false; // This variable is responsible for persisting all output that is yet to be associated with any @@ -77,7 +76,7 @@ private static synchronized void log(String s, ITestResult m) { if (m == null) { // Persist the output temporarily into a ThreadLocal String list. if (m_orphanedOutput.get() == null) { - m_orphanedOutput.set(new ArrayList<>()); + m_orphanedOutput.set(new LinkedList<>()); } m_orphanedOutput.get().add(s); return; @@ -86,7 +85,7 @@ private static synchronized void log(String s, ITestResult m) { // Synchronization needed to ensure the line number and m_output are updated atomically. int n = getOutput().size(); - List lines = m_methodOutputMap.computeIfAbsent(m.id(), k -> Lists.newArrayList()); + List lines = m_methodOutputMap.computeIfAbsent(m.id(), k -> Lists.newLinkedList()); // Check if there was already some orphaned output for the current thread. if (m_orphanedOutput.get() != null) { diff --git a/testng-core/src/main/java/org/testng/TestNG.java b/testng-core/src/main/java/org/testng/TestNG.java index d68e9c773b..fa0e81b642 100644 --- a/testng-core/src/main/java/org/testng/TestNG.java +++ b/testng-core/src/main/java/org/testng/TestNG.java @@ -55,7 +55,6 @@ import org.testng.reporters.FailedReporter; import org.testng.reporters.JUnitReportReporter; import org.testng.reporters.PerSuiteXMLReporter; -import org.testng.reporters.SuiteHTMLReporter; import org.testng.reporters.VerboseReporter; import org.testng.reporters.XMLReporter; import org.testng.reporters.jq.Main; @@ -937,7 +936,6 @@ private void initializeDefaultListeners() { this.exitCodeListener.failIfAllTestsSkipped(); } if (m_useDefaultListeners) { - addReporter(SuiteHTMLReporter.class); addReporter(Main.class); addReporter(FailedReporter.class); if (m_generateResultsPerSuite) { diff --git a/testng-core/src/main/java/org/testng/reporters/EmailableReporter.java b/testng-core/src/main/java/org/testng/reporters/EmailableReporter.java index 3d711f08b6..61d3f82ea8 100644 --- a/testng-core/src/main/java/org/testng/reporters/EmailableReporter.java +++ b/testng-core/src/main/java/org/testng/reporters/EmailableReporter.java @@ -33,8 +33,10 @@ /** * Reported designed to render self-contained HTML top down view of a testing suite. * + * @deprecated - This reporter is being deprecated in favour of the newer {@link EmailableReporter2} * @since 5.2 */ +@Deprecated public class EmailableReporter implements IReporter { private static final Logger L = Logger.getLogger(EmailableReporter.class); diff --git a/testng-core/src/main/java/org/testng/reporters/SuiteHTMLReporter.java b/testng-core/src/main/java/org/testng/reporters/SuiteHTMLReporter.java index 606f9bd0e2..bfbab33003 100644 --- a/testng-core/src/main/java/org/testng/reporters/SuiteHTMLReporter.java +++ b/testng-core/src/main/java/org/testng/reporters/SuiteHTMLReporter.java @@ -27,9 +27,12 @@ /** * This class implements an HTML reporter for suites. * + * @deprecated - This reporter is deprecated as of TestNG 7.9.0 in favour of {@link + * org.testng.reporters.jq.Main} * @author cbeust * @author Alexandru Popescu */ +@Deprecated public class SuiteHTMLReporter implements IReporter { public static final String METHODS_CHRONOLOGICAL = "methods.html"; public static final String METHODS_ALPHABETICAL = "methods-alphabetical.html";