jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject [jmeter] branch master updated: Various sonar fixes (#485)
Date Wed, 18 Sep 2019 07:18:40 GMT
This is an automated email from the ASF dual-hosted git repository.

pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new bb86cdb  Various sonar fixes (#485)
bb86cdb is described below

commit bb86cdb1ab4c597dbf7cfa352e0d86470c3c89a2
Author: Graham Russell <graham@ham1.co.uk>
AuthorDate: Wed Sep 18 08:18:33 2019 +0100

    Various sonar fixes (#485)
    
    * Used Guard Clauses where possible instead of nested ifs
    
    * Use Java 8 features to improve readability
    
    * Use richer assertions
    
    * Formatting/whitespace/comments
    
    * Naming for clarity
    
    * Remove if's around log statements for clarity
    
    * Minor readability changes
    
    * Rename variables and format test for RegexExtractor
    
    * Fix unused import
    
    * Fixed import order and checkstyle.xml indent
    
    * Fixes mistake and further improved HtmlTemplateExporter.
    
    * Reduce size of changes in CSVDataSet
    
    * Revert slower JSONPathAssertion changes.
    
    * Reverted boolean expression simplification
---
 config/checkstyle/checkstyle.xml                   |   2 +-
 .../jmeter/assertions/JSONPathAssertion.java       |  50 +-
 .../jmeter/assertions/ResponseAssertion.java       |   7 +-
 .../apache/jmeter/assertions/SMIMEAssertion.java   |  10 +-
 .../java/org/apache/jmeter/config/CSVDataSet.java  |  48 +-
 .../jmeter/control/gui/ForeachControlPanel.java    |  44 +-
 .../apache/jmeter/extractor/RegexExtractor.java    |  48 +-
 .../ConstantPoissonProcessGenerator.java           |   1 -
 .../org/apache/jmeter/visualizers/AxisGraph.java   |  14 +-
 .../jmeter/assertions/TestJSONPathAssertion.java   |  46 +-
 .../jmeter/extractor/TestRegexExtractor.java       | 712 ++++++++++-----------
 .../report/dashboard/AbstractDataExporter.java     |  45 +-
 .../report/dashboard/HtmlTemplateExporter.java     | 372 +++++------
 .../org/apache/commons/cli/avalon/CLOption.java    |   2 +-
 14 files changed, 678 insertions(+), 723 deletions(-)

diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index ed0c42c..69c99f0 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -132,7 +132,7 @@
     </module>
     <module name="RedundantImport"/>
     <module name="UnusedImports"/>
-   <module name="ImportOrder">
+    <module name="ImportOrder">
       <property name="groups" value="/^java\./,javax,org,net,com"/>
       <property name="ordered" value="true"/>
       <property name="separated" value="true"/>
diff --git a/src/components/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java b/src/components/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java
index dc34ef9..37e11c5 100644
--- a/src/components/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java
+++ b/src/components/src/main/java/org/apache/jmeter/assertions/JSONPathAssertion.java
@@ -109,30 +109,32 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
     private void doAssert(String jsonString) {
         Object value = JsonPath.read(jsonString, getJsonPath());
 
-        if (isJsonValidationBool()) {
-            if (value instanceof JSONArray) {
-                if (arrayMatched((JSONArray) value)) {
-                    return;
-                }
-            } else {
-                if (isExpectNull() && value == null) {
-                    return;
-                } else if (isEquals(value)) {
-                    return;
-                }
+        if (!isJsonValidationBool()) {
+            return;
+        }
+
+        if (value instanceof JSONArray) {
+            if (arrayMatched((JSONArray) value)) {
+                return;
+            }
+        } else {
+            if (isExpectNull() && value == null) {
+                return;
+            } else if (isEquals(value)) {
+                return;
             }
+        }
 
-            if (isExpectNull()) {
-                throw new IllegalStateException(String.format("Value expected to be null, but found '%s'", value));
+        if (isExpectNull()) {
+            throw new IllegalStateException(String.format("Value expected to be null, but found '%s'", value));
+        } else {
+            String msg;
+            if (isUseRegex()) {
+                msg = "Value expected to match regexp '%s', but it did not match: '%s'";
             } else {
-                String msg;
-                if (isUseRegex()) {
-                    msg="Value expected to match regexp '%s', but it did not match: '%s'";
-                } else {
-                    msg="Value expected to be '%s', but found '%s'";
-                }
-                throw new IllegalStateException(String.format(msg, getExpectedValue(), objectToString(value)));
+                msg = "Value expected to be '%s', but found '%s'";
             }
+            throw new IllegalStateException(String.format(msg, getExpectedValue(), objectToString(value)));
         }
     }
 
@@ -176,9 +178,7 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
             try {
                 doAssert(responseData);
             } catch (Exception e) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Assertion failed", e);
-                }
+                log.debug("Assertion failed", e);
                 result.setFailure(true);
                 result.setFailureMessage(e.getMessage());
             }
@@ -196,9 +196,7 @@ public class JSONPathAssertion extends AbstractTestElement implements Serializab
                     result.setFailureMessage("Failed that JSONPath not exists: " + getJsonPath());
                 }
             } catch (Exception e) {
-                if (log.isDebugEnabled()) {
-                    log.debug("Assertion failed", e);
-                }
+                log.debug("Assertion failed, as expected", e);
             }
         }
         return result;
diff --git a/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java b/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java
index e0dc91d..4c17830 100644
--- a/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java
+++ b/src/components/src/main/java/org/apache/jmeter/assertions/ResponseAssertion.java
@@ -300,8 +300,9 @@ public class ResponseAssertion extends AbstractScopedAssertion implements Serial
 
         result.setFailure(false);
         result.setError(false);
-        boolean notTest = (NOT & getTestType()) > 0;
-        boolean orTest = (OR & getTestType()) > 0;
+        int testType = getTestType();
+        boolean notTest = (NOT & testType) > 0;
+        boolean orTest = (OR & testType) > 0;
         boolean contains = isContainsType(); // do it once outside loop
         boolean equals = isEqualsType();
         boolean substring = isSubstringType();
@@ -487,7 +488,7 @@ public class ResponseAssertion extends AbstractScopedAssertion implements Serial
         } else if (right) {
             return str.substring(0, EQUALS_SECTION_DIFF_LEN) + EQUALS_DIFF_TRUNC;
         } else {
-            return EQUALS_DIFF_TRUNC + str.substring(str.length() - EQUALS_SECTION_DIFF_LEN, str.length());
+            return EQUALS_DIFF_TRUNC + str.substring(str.length() - EQUALS_SECTION_DIFF_LEN);
         }
     }
 
diff --git a/src/components/src/main/java/org/apache/jmeter/assertions/SMIMEAssertion.java b/src/components/src/main/java/org/apache/jmeter/assertions/SMIMEAssertion.java
index c844e5d..4c5ac1f 100644
--- a/src/components/src/main/java/org/apache/jmeter/assertions/SMIMEAssertion.java
+++ b/src/components/src/main/java/org/apache/jmeter/assertions/SMIMEAssertion.java
@@ -93,26 +93,26 @@ class SMIMEAssertion {
                 msg = getMessageFromResponse(response, msgPos);
             }
 
-            SMIMESignedParser s = null;
+            SMIMESignedParser signedParser = null;
             if(log.isDebugEnabled()) {
                 log.debug("Content-type: {}", msg.getContentType());
             }
             if (msg.isMimeType("multipart/signed")) { // $NON-NLS-1$
                 MimeMultipart multipart = (MimeMultipart) msg.getContent();
-                s = new SMIMESignedParser(new BcDigestCalculatorProvider(), multipart);
+                signedParser = new SMIMESignedParser(new BcDigestCalculatorProvider(), multipart);
             } else if (msg.isMimeType("application/pkcs7-mime") // $NON-NLS-1$
                     || msg.isMimeType("application/x-pkcs7-mime")) { // $NON-NLS-1$
-                s = new SMIMESignedParser(new BcDigestCalculatorProvider(), msg);
+                signedParser = new SMIMESignedParser(new BcDigestCalculatorProvider(), msg);
             }
 
-            if (null != s) {
+            if (null != signedParser) {
                 log.debug("Found signature");
 
                 if (testElement.isNotSigned()) {
                     res.setFailure(true);
                     res.setFailureMessage("Mime message is signed");
                 } else if (testElement.isVerifySignature() || !testElement.isSignerNoCheck()) {
-                    res = verifySignature(testElement, s, name);
+                    res = verifySignature(testElement, signedParser, name);
                 }
 
             } else {
diff --git a/src/components/src/main/java/org/apache/jmeter/config/CSVDataSet.java b/src/components/src/main/java/org/apache/jmeter/config/CSVDataSet.java
index f709a2f..a748a43 100644
--- a/src/components/src/main/java/org/apache/jmeter/config/CSVDataSet.java
+++ b/src/components/src/main/java/org/apache/jmeter/config/CSVDataSet.java
@@ -120,30 +120,36 @@ public class CSVDataSet extends ConfigTestElement
      */
     @Override
     public void setProperty(JMeterProperty property) {
-        if (property instanceof StringProperty) {
-            final String propName = property.getName();
-            if ("shareMode".equals(propName)) { // The original name of the property
-                final String propValue = property.getStringValue();
-                if (propValue.contains(" ")){ // variables are unlikely to contain spaces, so most likely a translation
-                    try {
-                        final BeanInfo beanInfo = Introspector.getBeanInfo(this.getClass());
-                        final ResourceBundle rb = (ResourceBundle) beanInfo.getBeanDescriptor().getValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE);
-                        for(String resKey : CSVDataSetBeanInfo.getShareTags()) {
-                            if (propValue.equals(rb.getString(resKey))) {
-                                if (log.isDebugEnabled()) {
-                                    log.debug("Converted {}={} to {} using Locale: {}", propName, propValue, resKey, rb.getLocale());
-                                }
-                                ((StringProperty) property).setValue(resKey); // reset the value
-                                super.setProperty(property);
-                                return;
-                            }
+        if (!(property instanceof StringProperty)) {
+            super.setProperty(property);
+            return;
+        }
+
+        final String propName = property.getName();
+        if (!"shareMode".equals(propName)) {
+            super.setProperty(property);
+            return;
+        }
+
+        final String propValue = property.getStringValue();
+        if (propValue.contains(" ")) { // variables are unlikely to contain spaces, so most likely a translation
+            try {
+                final BeanInfo beanInfo = Introspector.getBeanInfo(this.getClass());
+                final ResourceBundle rb = (ResourceBundle) beanInfo.getBeanDescriptor().getValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE);
+                for (String resKey : CSVDataSetBeanInfo.getShareTags()) {
+                    if (propValue.equals(rb.getString(resKey))) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("Converted {}={} to {} using Locale: {}", propName, propValue, resKey, rb.getLocale());
                         }
-                        // This could perhaps be a variable name
-                        log.warn("Could not translate {}={} using Locale: {}", propName, propValue, rb.getLocale());
-                    } catch (IntrospectionException e) {
-                        log.error("Could not find BeanInfo; cannot translate shareMode entries", e);
+                        ((StringProperty) property).setValue(resKey); // reset the value
+                        super.setProperty(property);
+                        return;
                     }
                 }
+                // This could perhaps be a variable name
+                log.warn("Could not translate {}={} using Locale: {}", propName, propValue, rb.getLocale());
+            } catch (IntrospectionException e) {
+                log.error("Could not find BeanInfo; cannot translate shareMode entries", e);
             }
         }
         super.setProperty(property);
diff --git a/src/components/src/main/java/org/apache/jmeter/control/gui/ForeachControlPanel.java b/src/components/src/main/java/org/apache/jmeter/control/gui/ForeachControlPanel.java
index 9bb1a1d..4a6afdb 100644
--- a/src/components/src/main/java/org/apache/jmeter/control/gui/ForeachControlPanel.java
+++ b/src/components/src/main/java/org/apache/jmeter/control/gui/ForeachControlPanel.java
@@ -32,10 +32,9 @@ import org.apache.jmeter.util.JMeterUtils;
 
 /**
  * The user interface for a foreach controller which specifies that its
- * subcomponents should be executed some number of times in a loop. This
+ * sub-components should be executed some number of times in a loop. This
  * component can be used standalone or embedded into some other component.
  */
-
 public class ForeachControlPanel extends AbstractControllerGui {
 
     private static final long serialVersionUID = 240L;
@@ -46,14 +45,10 @@ public class ForeachControlPanel extends AbstractControllerGui {
      */
     private JTextField inputVal;
 
-    /**
-     * A field allowing the user to specify the indice start of the loop
-     */
+    /** A field allowing the user to specify the indice start of the loop */
     private JTextField startIndex;
 
-    /**
-     * A field allowing the user to specify the indice end of the loop
-     */
+    /** A field allowing the user to specify the indice end of the loop */
     private JTextField endIndex;
 
     /**
@@ -68,21 +63,21 @@ public class ForeachControlPanel extends AbstractControllerGui {
     /**
      * Boolean indicating whether or not this component should display its name.
      * If true, this is a standalone component. If false, this component is
-     * intended to be used as a subpanel for another component.
+     * intended to be used as a sub-panel for another component.
      */
     private boolean displayName = true;
 
     /** The name of the infinite checkbox component. */
-    private static final String INPUTVAL = "Input Field"; // $NON-NLS-1$
+    private static final String INPUT_VAL_NAME = "Input Field"; // $NON-NLS-1$
 
     /** The name of the loops field component. */
-    private static final String RETURNVAL = "Return Field"; // $NON-NLS-1$
+    private static final String RETURN_VAL_NAME = "Return Field"; // $NON-NLS-1$
 
     /** The name of the start index field component. */
-    private static final String START_INDEX = "Start Index Field"; // $NON-NLS-1$
+    private static final String START_INDEX_NAME = "Start Index Field"; // $NON-NLS-1$
 
     /** The name of the end index field component. */
-    private static final String END_INDEX = "End Index Field"; // $NON-NLS-1$
+    private static final String END_INDEX_NAME = "End Index Field"; // $NON-NLS-1$
     /**
      * Create a new LoopControlPanel as a standalone component.
      */
@@ -146,9 +141,7 @@ public class ForeachControlPanel extends AbstractControllerGui {
         }
     }
 
-    /**
-     * Implements JMeterGUIComponent.clearGui
-     */
+    /** Implements JMeterGUIComponent.clearGui */
     @Override
     public void clearGui() {
         super.clearGui();
@@ -160,21 +153,18 @@ public class ForeachControlPanel extends AbstractControllerGui {
         useSeparator.setSelected(true);
     }
 
-
     @Override
     public String getLabelResource() {
         return "foreach_controller_title"; // $NON-NLS-1$
     }
 
-    /**
-     * Initialize the GUI components and layout for this component.
-     */
-    private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
+    /** Initialize the GUI components and layout for this component. */
+    private void init() {
+        // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
         // The Loop Controller panel can be displayed standalone or inside
         // another panel. For standalone, we want to display the TITLE, NAME,
         // etc. (everything). However, if we want to display it within another
-        // panel, we just display the Loop Count fields (not the TITLE and
-        // NAME).
+        // panel, we just display the Loop Count fields (not the TITLE and NAME).
 
         // Standalone
         if (displayName) {
@@ -210,7 +200,7 @@ public class ForeachControlPanel extends AbstractControllerGui {
         // TEXT FIELD
         JPanel inputValSubPanel = new JPanel(new BorderLayout(5, 0));
         inputVal = new JTextField("", 5); // $NON-NLS-1$
-        inputVal.setName(INPUTVAL);
+        inputVal.setName(INPUT_VAL_NAME);
         inputValLabel.setLabelFor(inputVal);
         inputValSubPanel.add(inputValLabel, BorderLayout.WEST);
         inputValSubPanel.add(inputVal, BorderLayout.CENTER);
@@ -218,7 +208,7 @@ public class ForeachControlPanel extends AbstractControllerGui {
         // TEXT FIELD
         JPanel startIndexSubPanel = new JPanel(new BorderLayout(5, 0));
         startIndex = new JTextField("", 5); // $NON-NLS-1$
-        startIndex.setName(START_INDEX);
+        startIndex.setName(START_INDEX_NAME);
         startIndexLabel.setLabelFor(startIndex);
         startIndexSubPanel.add(startIndexLabel, BorderLayout.WEST);
         startIndexSubPanel.add(startIndex, BorderLayout.CENTER);
@@ -226,7 +216,7 @@ public class ForeachControlPanel extends AbstractControllerGui {
         // TEXT FIELD
         JPanel endIndexSubPanel = new JPanel(new BorderLayout(5, 0));
         endIndex = new JTextField("", 5); // $NON-NLS-1$
-        endIndex.setName(END_INDEX);
+        endIndex.setName(END_INDEX_NAME);
         endIndexLabel.setLabelFor(endIndex);
         endIndexSubPanel.add(endIndexLabel, BorderLayout.WEST);
         endIndexSubPanel.add(endIndex, BorderLayout.CENTER);
@@ -234,7 +224,7 @@ public class ForeachControlPanel extends AbstractControllerGui {
         // TEXT FIELD
         JPanel returnValSubPanel = new JPanel(new BorderLayout(5, 0));
         returnVal = new JTextField("", 5); // $NON-NLS-1$
-        returnVal.setName(RETURNVAL);
+        returnVal.setName(RETURN_VAL_NAME);
         returnValLabel.setLabelFor(returnVal);
         returnValSubPanel.add(returnValLabel, BorderLayout.WEST);
         returnValSubPanel.add(returnVal, BorderLayout.CENTER);
diff --git a/src/components/src/main/java/org/apache/jmeter/extractor/RegexExtractor.java b/src/components/src/main/java/org/apache/jmeter/extractor/RegexExtractor.java
index f5452db..37b65ae 100644
--- a/src/components/src/main/java/org/apache/jmeter/extractor/RegexExtractor.java
+++ b/src/components/src/main/java/org/apache/jmeter/extractor/RegexExtractor.java
@@ -42,8 +42,6 @@ import org.apache.oro.text.regex.Perl5Matcher;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-// @see org.apache.jmeter.extractor.TestRegexExtractor for unit tests
-
 public class RegexExtractor extends AbstractScopedTestElement implements PostProcessor, Serializable {
 
     private static final long serialVersionUID = 242L;
@@ -70,18 +68,12 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
     public static final String USE_CODE = "code"; // $NON-NLS-1$
     public static final String USE_MESSAGE = "message"; // $NON-NLS-1$
 
-
-    private static final String REGEX = "RegexExtractor.regex"; // $NON-NLS-1$
-
-    private static final String REFNAME = "RegexExtractor.refname"; // $NON-NLS-1$
-
-    private static final String MATCH_NUMBER = "RegexExtractor.match_number"; // $NON-NLS-1$
-
-    private static final String DEFAULT = "RegexExtractor.default"; // $NON-NLS-1$
-
-    private static final String DEFAULT_EMPTY_VALUE = "RegexExtractor.default_empty_value"; // $NON-NLS-1$
-
-    private static final String TEMPLATE = "RegexExtractor.template"; // $NON-NLS-1$
+    private static final String REGEX_PROP = "RegexExtractor.regex"; // $NON-NLS-1$
+    private static final String REFNAME_PROP = "RegexExtractor.refname"; // $NON-NLS-1$
+    private static final String MATCH_NUMBER_PROP = "RegexExtractor.match_number"; // $NON-NLS-1$
+    private static final String DEFAULT_PROP = "RegexExtractor.default"; // $NON-NLS-1$
+    private static final String DEFAULT_EMPTY_VALUE_PROP = "RegexExtractor.default_empty_value"; // $NON-NLS-1$
+    private static final String TEMPLATE_PROP = "RegexExtractor.template"; // $NON-NLS-1$
 
     private static final String REF_MATCH_NR = "_matchNr"; // $NON-NLS-1$
 
@@ -381,7 +373,7 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      * @param regex The string representation of the regex
      */
     public void setRegex(String regex) {
-        setProperty(REGEX, regex);
+        setProperty(REGEX_PROP, regex);
     }
 
     /**
@@ -389,7 +381,7 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      * @return string representing the regex
      */
     public String getRegex() {
-        return getPropertyAsString(REGEX);
+        return getPropertyAsString(REGEX_PROP);
     }
 
     /**
@@ -397,7 +389,7 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      * @param refName prefix of the variables to be used
      */
     public void setRefName(String refName) {
-        setProperty(REFNAME, refName);
+        setProperty(REFNAME_PROP, refName);
     }
 
     /**
@@ -405,7 +397,7 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      * @return The prefix of the variables to be used
      */
     public String getRefName() {
-        return getPropertyAsString(REFNAME);
+        return getPropertyAsString(REFNAME_PROP);
     }
 
     /**
@@ -418,19 +410,19 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      *            random match should be used.
      */
     public void setMatchNumber(int matchNumber) {
-        setProperty(new IntegerProperty(MATCH_NUMBER, matchNumber));
+        setProperty(new IntegerProperty(MATCH_NUMBER_PROP, matchNumber));
     }
 
     public void setMatchNumber(String matchNumber) {
-        setProperty(MATCH_NUMBER, matchNumber);
+        setProperty(MATCH_NUMBER_PROP, matchNumber);
     }
 
     public int getMatchNumber() {
-        return getPropertyAsInt(MATCH_NUMBER);
+        return getPropertyAsInt(MATCH_NUMBER_PROP);
     }
 
     public String getMatchNumberAsString() {
-        return getPropertyAsString(MATCH_NUMBER);
+        return getPropertyAsString(MATCH_NUMBER_PROP);
     }
 
     /**
@@ -439,7 +431,7 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      * @param defaultValue The default value for the variable
      */
     public void setDefaultValue(String defaultValue) {
-        setProperty(DEFAULT, defaultValue);
+        setProperty(DEFAULT_PROP, defaultValue);
     }
 
     /**
@@ -448,7 +440,7 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      * @param defaultEmptyValue The default value for the variable
      */
     public void setDefaultEmptyValue(boolean defaultEmptyValue) {
-        setProperty(DEFAULT_EMPTY_VALUE, defaultEmptyValue, DEFAULT_VALUE_FOR_DEFAULT_EMPTY_VALUE);
+        setProperty(DEFAULT_EMPTY_VALUE_PROP, defaultEmptyValue, DEFAULT_VALUE_FOR_DEFAULT_EMPTY_VALUE);
     }
 
     /**
@@ -458,7 +450,7 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      * @return The default value for the variable
      */
     public String getDefaultValue() {
-        return getPropertyAsString(DEFAULT);
+        return getPropertyAsString(DEFAULT_PROP);
     }
 
     /**
@@ -466,15 +458,15 @@ public class RegexExtractor extends AbstractScopedTestElement implements PostPro
      * @return true if we should set default value to "" if variable cannot be extracted
      */
     public boolean isEmptyDefaultValue() {
-        return getPropertyAsBoolean(DEFAULT_EMPTY_VALUE, DEFAULT_VALUE_FOR_DEFAULT_EMPTY_VALUE);
+        return getPropertyAsBoolean(DEFAULT_EMPTY_VALUE_PROP, DEFAULT_VALUE_FOR_DEFAULT_EMPTY_VALUE);
     }
 
     public void setTemplate(String template) {
-        setProperty(TEMPLATE, template);
+        setProperty(TEMPLATE_PROP, template);
     }
 
     public String getTemplate() {
-        return getPropertyAsString(TEMPLATE);
+        return getPropertyAsString(TEMPLATE_PROP);
     }
 
     public boolean useHeaders() {
diff --git a/src/components/src/main/java/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java b/src/components/src/main/java/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java
index 032e5d6..e8c3f88 100644
--- a/src/components/src/main/java/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java
+++ b/src/components/src/main/java/org/apache/jmeter/timers/poissonarrivals/ConstantPoissonProcessGenerator.java
@@ -144,7 +144,6 @@ public class ConstantPoissonProcessGenerator implements EventProducer {
                 }
                 log.info(sb.toString());
             }
-
         }
         events.flip();
         if (batchSize > 1) {
diff --git a/src/components/src/main/java/org/apache/jmeter/visualizers/AxisGraph.java b/src/components/src/main/java/org/apache/jmeter/visualizers/AxisGraph.java
index 0009609..4685389 100644
--- a/src/components/src/main/java/org/apache/jmeter/visualizers/AxisGraph.java
+++ b/src/components/src/main/java/org/apache/jmeter/visualizers/AxisGraph.java
@@ -50,7 +50,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- *
  * Axis graph is used by StatGraphVisualizer, which generates bar graphs
  * from the statistical data.
  */
@@ -344,14 +343,8 @@ public class AxisGraph extends JPanel {
             Font legendFont, Graphics g) {
         double max = maxYAxisScale > 0 ? maxYAxisScale : findMax(_data); // define max scale y axis
         try {
-            /** These controls are already done in StatGraphVisualizer
-            if (_width == 0) {
-                _width = 450;
-            }
-            if (_height == 0) {
-                _height = 250;
-            }
-            **/
+            // Width and Height are already set in StatGraphVisualizer
+
             if (_maxLength < 3) {
                 _maxLength = 3;
             }
@@ -365,7 +358,8 @@ public class AxisGraph extends JPanel {
                 _xAxisLabels[i]=squeeze(label, _maxLength);
             }
             this.setPreferredSize(new Dimension(_width,_height));
-            DataSeries dataSeries = new DataSeries( _xAxisLabels, null, _yAxisTitle, _title ); // replace _xAxisTitle to null (don't display x axis title)
+            // _xAxisTitle to null (don't display x axis title)
+            DataSeries dataSeries = new DataSeries( _xAxisLabels, null, _yAxisTitle, _title );
 
             ClusteredBarChartProperties clusteredBarChartProperties= new ClusteredBarChartProperties();
             clusteredBarChartProperties.setShowOutlinesFlag(outlinesBarFlag);
diff --git a/src/components/src/test/java/org/apache/jmeter/assertions/TestJSONPathAssertion.java b/src/components/src/test/java/org/apache/jmeter/assertions/TestJSONPathAssertion.java
index ea6023e..3efb1e0 100644
--- a/src/components/src/test/java/org/apache/jmeter/assertions/TestJSONPathAssertion.java
+++ b/src/components/src/test/java/org/apache/jmeter/assertions/TestJSONPathAssertion.java
@@ -18,6 +18,8 @@
 package org.apache.jmeter.assertions;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Locale;
 
@@ -66,7 +68,7 @@ public class TestJSONPathAssertion {
     public void testIsJsonValidationBool() {
         JSONPathAssertion instance = new JSONPathAssertion();
         boolean result = instance.isJsonValidationBool();
-        assertEquals(false, result);
+        assertFalse(result);
     }
 
     @Test
@@ -81,7 +83,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
     }
 
     @Test
@@ -96,11 +98,11 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
 
         samplerResult.setResponseData("{\"myval\": 456}".getBytes());
         AssertionResult result2 = instance.getResult(samplerResult);
-        assertEquals(false, result2.isFailure());
+        assertFalse(result2.isFailure());
     }
 
     @Test
@@ -115,7 +117,7 @@ public class TestJSONPathAssertion {
         instance.setInvert(true);
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
-        assertEquals(true, result.isFailure());
+        assertTrue(result.isFailure());
         assertEquals(expResult.getName(), result.getName());
     }
 
@@ -129,11 +131,11 @@ public class TestJSONPathAssertion {
         instance.setJsonValidationBool(true);
         instance.setExpectedValue("some.+");
         AssertionResult result = instance.getResult(samplerResult);
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
 
         instance.setIsRegex(false);
         AssertionResult result2 = instance.getResult(samplerResult);
-        assertEquals(true, result2.isFailure());
+        assertTrue(result2.isFailure());
     }
 
     @Test
@@ -148,7 +150,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(true, result.isFailure());
+        assertTrue(result.isFailure());
     }
 
     @Test
@@ -163,7 +165,7 @@ public class TestJSONPathAssertion {
         instance.setInvert(true);
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
         assertEquals(expResult.getName(), result.getName());
     }
 
@@ -179,7 +181,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
     }
 
     @Test
@@ -194,7 +196,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(true, result.isFailure());
+        assertTrue(result.isFailure());
     }
 
     @Test
@@ -208,7 +210,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
     }
 
     @Test
@@ -222,7 +224,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(true, result.isFailure());
+        assertTrue(result.isFailure());
     }
 
     @Test
@@ -237,7 +239,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
     }
 
     @Test
@@ -252,7 +254,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(true, result.isFailure());
+        assertTrue(result.isFailure());
     }
 
     @Test
@@ -266,7 +268,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
     }
 
     @Test
@@ -281,7 +283,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
     }
 
     @Test
@@ -296,7 +298,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
     }
 
     @Test
@@ -312,7 +314,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(true, result.isFailure());
+        assertTrue(result.isFailure());
     }
 
     @Test
@@ -330,7 +332,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(true, result.isFailure());
+        assertTrue(result.isFailure());
         assertEquals(
                 "Value expected to match regexp '{headerkey=header value}', but it did not match: '{\"headerkey\":\"header value\"}'",
                 result.getFailureMessage());
@@ -364,7 +366,7 @@ public class TestJSONPathAssertion {
         AssertionResult expResult = new AssertionResult("");
         AssertionResult result = instance.getResult(samplerResult);
         assertEquals(expResult.getName(), result.getName());
-        assertEquals(false, result.isFailure());
+        assertFalse(result.isFailure());
     }
 
     @Test
@@ -386,7 +388,7 @@ public class TestJSONPathAssertion {
             AssertionResult expResult = new AssertionResult("");
             AssertionResult result = instance.getResult(samplerResult);
             assertEquals(expResult.getName(), result.getName());
-            assertEquals(false, result.isFailure());
+            assertFalse(result.isFailure());
         } finally {
             Locale.setDefault(prevLocale);
         }
diff --git a/src/components/src/test/java/org/apache/jmeter/extractor/TestRegexExtractor.java b/src/components/src/test/java/org/apache/jmeter/extractor/TestRegexExtractor.java
index 7eb6280..18ab07b 100644
--- a/src/components/src/test/java/org/apache/jmeter/extractor/TestRegexExtractor.java
+++ b/src/components/src/test/java/org/apache/jmeter/extractor/TestRegexExtractor.java
@@ -38,364 +38,361 @@ import org.junit.Test;
 
 public class TestRegexExtractor {
 
-        private RegexExtractor extractor;
-
-        private SampleResult result;
-
-        private JMeterVariables vars;
-
-        private JMeterContext jmctx;
-
-        @Before
-        public void setUp() {
-            jmctx = JMeterContextService.getContext();
-            extractor = new RegexExtractor();
-            extractor.setThreadContext(jmctx);// This would be done by the run
-                                                // command
-            extractor.setRefName("regVal");
-            result = new SampleResult();
-            String data = "<company-xmlext-query-ret>" + "<row>" + "<value field=\"RetCode\">LIS_OK</value>"
-                    + "<value field=\"RetCodeExtension\"></value>" + "<value field=\"alias\"></value>"
-                    + "<value field=\"positioncount\"></value>" + "<value field=\"invalidpincount\">0</value>"
-                    + "<value field=\"pinposition1\">1</value>" + "<value field=\"pinpositionvalue1\"></value>"
-                    + "<value field=\"pinposition2\">5</value>" + "<value field=\"pinpositionvalue2\"></value>"
-                    + "<value field=\"pinposition3\">6</value>" + "<value field=\"pinpositionvalue3\"></value>"
-                    + "</row>" + "</company-xmlext-query-ret>";
-            result.setResponseData(data, null);
-            result.setResponseHeaders("Header1: Value1\nHeader2: Value2");
-            result.setResponseCode("abcd");
-            result.setResponseMessage("The quick brown fox");
-            vars = new JMeterVariables();
-            jmctx.setVariables(vars);
-            jmctx.setPreviousResult(result);
-        }
-
-        @Test
-        public void testProcessAllElementsSingleMatch() {
-            vars.put("content", "one");
-            extractor.setMatchNumber(-1);
-            extractor.setRefName("varname");
-            extractor.setRegex("(\\w+)");
-            extractor.setScopeVariable("content");
-            extractor.setThreadContext(jmctx);
-            extractor.setTemplate("$1$");
-            extractor.process();
-            assertThat(vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
-            assertThat(vars.get("varname_1"), CoreMatchers.is("one"));
-            assertThat(vars.get("varname_matchNr"), CoreMatchers.is("1"));
-        }
-
-        @Test
-        public void testProcessAllElementsMultipleMatches() {
-            vars.put("content", "one, two");
-            extractor.setMatchNumber(-1);
-            extractor.setRefName("varname");
-            extractor.setRegex("(\\w+)");
-            extractor.setScopeVariable("content");
-            extractor.setThreadContext(jmctx);
-            extractor.setTemplate("$1$");
-            extractor.process();
-            assertThat(vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
-            assertThat(vars.get("varname_1"), CoreMatchers.is("one"));
-            assertThat(vars.get("varname_2"), CoreMatchers.is("two"));
-            assertThat(vars.get("varname_matchNr"), CoreMatchers.is("2"));
-        }
-
-        @Test
-        public void testEmptyDefaultVariable() throws Exception {
-            extractor.setRegex("<value name=\"positioncount\">(.+?)</value>");
-            extractor.setTemplate("$1$");
-            extractor.setMatchNumber(1);
-            extractor.setDefaultEmptyValue(true);
-            extractor.process();
-            assertEquals("", vars.get("regVal"));
-        }
-
-        @Test
-        public void testNotEmptyDefaultVariable() throws Exception {
-            extractor.setRegex("<value name=\"positioncount\">(.+?)</value>");
-            extractor.setTemplate("$1$");
-            extractor.setMatchNumber(1);
-            extractor.setDefaultEmptyValue(false);
-            extractor.process();
-            assertNull(vars.get("regVal"));
-        }
-
-        @Test
-        public void testVariableExtraction0() throws Exception {
-            extractor.setRegex("<(value) field=\"");
-            extractor.setTemplate("$1$");
-            extractor.setMatchNumber(0);
-            extractor.process();
-            assertEquals("value", vars.get("regVal"));
-        }
-
-        @Test
-        public void testVariableExtraction() throws Exception {
-            extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
-            extractor.setTemplate("$2$");
-            extractor.setMatchNumber(2);
-            extractor.process();
-            assertEquals("5", vars.get("regVal"));
-            assertEquals("pinposition2", vars.get("regVal_g1"));
-            assertEquals("5", vars.get("regVal_g2"));
-            assertEquals("<value field=\"pinposition2\">5</value>", vars.get("regVal_g0"));
-            assertNull(vars.get("regVal_g3"));
-            assertEquals("2",vars.get("regVal_g"));
-        }
-
-        private static void templateSetup(RegexExtractor rex, String tmp) {
-            rex.setRegex("<company-(\\w+?)-(\\w+?)-(\\w+?)>");
-            rex.setMatchNumber(1);
-            rex.setTemplate(tmp);
-            rex.process();
-        }
-
-        @Test
-        public void testTemplate1() throws Exception {
-            templateSetup(extractor, "");
-            assertEquals("<company-xmlext-query-ret>", vars.get("regVal_g0"));
-            assertEquals("xmlext", vars.get("regVal_g1"));
-            assertEquals("query", vars.get("regVal_g2"));
-            assertEquals("ret", vars.get("regVal_g3"));
-            assertEquals("", vars.get("regVal"));
-            assertEquals("3",vars.get("regVal_g"));
-        }
-
-        @Test
-        public void testTemplate2() throws Exception {
-            templateSetup(extractor, "ABC");
-            assertEquals("ABC", vars.get("regVal"));
-        }
-
-        @Test
-        public void testTemplate3() throws Exception {
-            templateSetup(extractor, "$2$");
-            assertEquals("query", vars.get("regVal"));
-        }
-
-        @Test
-        public void testTemplate4() throws Exception {
-            templateSetup(extractor, "PRE$2$");
-            assertEquals("PREquery", vars.get("regVal"));
-        }
-
-        @Test
-        public void testTemplate5() throws Exception {
-            templateSetup(extractor, "$2$POST");
-            assertEquals("queryPOST", vars.get("regVal"));
-        }
-
-        @Test
-        public void testTemplate6() throws Exception {
-            templateSetup(extractor, "$2$$1$");
-            assertEquals("queryxmlext", vars.get("regVal"));
-        }
-
-        @Test
-        public void testTemplate7() throws Exception {
-            templateSetup(extractor, "$2$MID$1$");
-            assertEquals("queryMIDxmlext", vars.get("regVal"));
-        }
-
-        @Test
-        public void testVariableExtraction2() throws Exception {
-            extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
-            extractor.setTemplate("$1$");
-            extractor.setMatchNumber(3);
-            extractor.process();
-            assertEquals("pinposition3", vars.get("regVal"));
-        }
-
-        @Test
-        public void testVariableExtraction6() throws Exception {
-            extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
-            extractor.setTemplate("$2$");
-            extractor.setMatchNumber(4);
-            extractor.setDefaultValue("default");
-            extractor.process();
-            assertEquals("default", vars.get("regVal"));
-        }
-
-        @Test
-        public void testVariableExtraction3() throws Exception {
-            extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
-            extractor.setTemplate("_$1$");
-            extractor.setMatchNumber(2);
-            extractor.process();
-            assertEquals("_pinposition2", vars.get("regVal"));
-        }
-
-        @Test
-        public void testVariableExtraction5() throws Exception {
-            extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
-            extractor.setTemplate("$1$");
-            extractor.setMatchNumber(1);// Set up the non-wild variables
-            extractor.process();
-            assertNotNull(vars.get("regVal"));
-            assertEquals("2",vars.get("regVal_g"));
-            assertNotNull(vars.get("regVal_g0"));
-            assertNotNull(vars.get("regVal_g1"));
-            assertNotNull(vars.get("regVal_g2"));
-
-            extractor.setMatchNumber(-1);
-            extractor.process();
-            assertNotNull(vars.get("regVal"));// Should not clear this?
-            assertNull(vars.get("regVal_g"));
-            assertNull(vars.get("regVal_g1"));
-            assertNull(vars.get("regVal_g2"));
-            assertEquals("3", vars.get("regVal_matchNr"));
-            assertEquals("pinposition1", vars.get("regVal_1"));
-            assertEquals("pinposition2", vars.get("regVal_2"));
-            assertEquals("pinposition3", vars.get("regVal_3"));
-            assertEquals("2", vars.get("regVal_1_g"));
-            assertEquals("pinposition1", vars.get("regVal_1_g1"));
-            assertEquals("1", vars.get("regVal_1_g2"));
-            assertEquals("6", vars.get("regVal_3_g2"));
-            assertEquals("<value field=\"pinposition1\">1</value>", vars.get("regVal_1_g0"));
-            assertNull(vars.get("regVal_4"));
-
-            // Check old values don't hang around:
-            extractor.setRegex("(\\w+)count"); // fewer matches
-            extractor.process();
-            assertEquals("2", vars.get("regVal_matchNr"));
-            assertEquals("position", vars.get("regVal_1"));
-            assertEquals("1", vars.get("regVal_1_g"));
-            assertEquals("position", vars.get("regVal_1_g1"));
-            assertNull("Unused variables should be null", vars.get("regVal_1_g2"));
-            assertEquals("invalidpin", vars.get("regVal_2"));
-            assertEquals("1", vars.get("regVal_2_g"));
-            assertEquals("invalidpin", vars.get("regVal_2_g1"));
-            assertNull("Unused variables should be null", vars.get("regVal_2_g2"));
-            assertEquals("1", vars.get("regVal_1_g"));
-            assertNull("Unused variables should be null", vars.get("regVal_3"));
-            assertNull("Unused variables should be null", vars.get("regVal_3_g"));
-            assertNull("Unused variables should be null", vars.get("regVal_3_g0"));
-            assertNull("Unused variables should be null", vars.get("regVal_3_g1"));
-            assertNull("Unused variables should be null", vars.get("regVal_3_g2"));
-
-            // Check when match fails
-            extractor.setRegex("xxxx(.)(.)");
-            extractor.process();
-            assertEquals("0", vars.get("regVal_matchNr"));
-            assertNull("Unused variables should be null", vars.get("regVal_1"));
-            assertNull("Unused variables should be null", vars.get("regVal_1_g0"));
-            assertNull("Unused variables should be null", vars.get("regVal_1_g1"));
-            assertNull("Unused variables should be null", vars.get("regVal_1_g2"));
-        }
-
-        @Test
-        public void testVariableExtraction7() throws Exception {
-            extractor.setRegex("Header1: (\\S+)");
-            extractor.setTemplate("$1$");
-            extractor.setMatchNumber(1);
-            assertTrue("useBody should be true", extractor.useBody());
-            assertFalse("useHdrs should be false", extractor.useHeaders());
-            assertFalse("useURL should be false", extractor.useUrl());
-            extractor.setUseField(RegexExtractor.USE_BODY);
-            assertTrue("useBody should be true", extractor.useBody());
-            assertFalse("useHdrs should be false", extractor.useHeaders());
-            assertFalse("useURL should be false", extractor.useUrl());
-            extractor.setUseField(RegexExtractor.USE_HDRS);
-            assertTrue("useHdrs should be true", extractor.useHeaders());
-            assertFalse("useBody should be false", extractor.useBody());
-            assertFalse("useURL should be false", extractor.useUrl());
-            extractor.process();
-            assertEquals("Value1", vars.get("regVal"));
-            extractor.setUseField(RegexExtractor.USE_URL);
-            assertFalse("useHdrs should be false", extractor.useHeaders());
-            assertFalse("useBody should be false", extractor.useBody());
-            assertTrue("useURL should be true", extractor.useUrl());
-        }
-
-        @Test
-        public void testVariableExtraction8() throws Exception {
-            extractor.setRegex("http://jakarta\\.apache\\.org/(\\w+)");
-            extractor.setTemplate("$1$");
-            extractor.setMatchNumber(1);
-            extractor.setUseField(RegexExtractor.USE_URL);
-            assertFalse("useHdrs should be false", extractor.useHeaders());
-            assertFalse("useBody should be false", extractor.useBody());
-            assertTrue("useURL should be true", extractor.useUrl());
-            extractor.process();
-            assertNull(vars.get("regVal"));
-            result.setURL(new URL("http://jakarta.apache.org/index.html?abcd"));
-            extractor.process();
-            assertEquals("index",vars.get("regVal"));
-        }
-
-        @Test
-        public void testVariableExtraction9() throws Exception {
-            extractor.setRegex("(\\w+)");
-            extractor.setTemplate("$1$");
-            extractor.setMatchNumber(1);
-            extractor.setUseField(RegexExtractor.USE_CODE);
-            assertFalse("useHdrs should be false", extractor.useHeaders());
-            assertFalse("useBody should be false", extractor.useBody());
-            assertFalse("useURL should be false", extractor.useUrl());
-            assertFalse("useMessage should be false", extractor.useMessage());
-            assertTrue("useCode should be true", extractor.useCode());
-            extractor.process();
-            assertEquals("abcd",vars.get("regVal"));
-            extractor.setUseField(RegexExtractor.USE_MESSAGE);
-            assertFalse("useHdrs should be false", extractor.useHeaders());
-            assertFalse("useBody should be false", extractor.useBody());
-            assertFalse("useURL should be false", extractor.useUrl());
-            assertTrue("useMessage should be true", extractor.useMessage());
-            assertFalse("useCode should be false", extractor.useCode());
-            extractor.setMatchNumber(3);
-            extractor.process();
-            assertEquals("brown",vars.get("regVal"));
-        }
-
-        @Test
-        public void testNoDefault() throws Exception {
-            extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
-            extractor.setTemplate("$2$");
-            extractor.setMatchNumber(4);
-            vars.put("regVal", "initial");
-            assertEquals("initial", vars.get("regVal"));
-            extractor.process();
-            assertEquals("initial", vars.get("regVal"));
-        }
-
-        @Test
-        public void testDefault() throws Exception {
-            extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
-            extractor.setTemplate("$2$");
-            extractor.setMatchNumber(999);
-            extractor.setDefaultValue("default");
-            vars.put("regVal", "initial");
-            assertEquals("initial", vars.get("regVal"));
-            extractor.process();
-            assertEquals("default", vars.get("regVal"));
-            assertNull(vars.get("regVal_g0"));
-            assertNull(vars.get("regVal_g1"));
-        }
-
-        @Test
-        public void testStaleVariables() throws Exception {
-            extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
-            extractor.setTemplate("$2$");
-            extractor.setMatchNumber(1);
-            extractor.setDefaultValue("default");
-            extractor.process();
-            assertEquals("1", vars.get("regVal"));
-            assertEquals("1", vars.get("regVal_g2"));
-            assertEquals("2", vars.get("regVal_g"));
-            assertNotNull(vars.get("regVal_g0"));
-            assertNotNull(vars.get("regVal_g1"));
-            // Now rerun with match fail
-            extractor.setMatchNumber(10);
-            extractor.process();
-            assertEquals("default", vars.get("regVal"));
-            assertNull(vars.get("regVal_g0"));
-            assertNull(vars.get("regVal_g1"));
-            assertNull(vars.get("regVal_g"));
-        }
+    private RegexExtractor extractor;
+    private SampleResult result;
+    private JMeterVariables vars;
+    private JMeterContext jmctx;
+
+    @Before
+    public void setUp() {
+        jmctx = JMeterContextService.getContext();
+        extractor = new RegexExtractor();
+        // This would be done by the run command
+        extractor.setThreadContext(jmctx);
+        extractor.setRefName("regVal");
+        result = new SampleResult();
+        String data = "<company-xmlext-query-ret><row><value field=\"RetCode\">LIS_OK</value>\n" +
+                "<value field=\"RetCodeExtension\"></value><value field=\"alias\"></value>\n" +
+                "<value field=\"positioncount\"></value><value field=\"invalidpincount\">0</value>\n" +
+                "<value field=\"pinposition1\">1</value><value field=\"pinpositionvalue1\"></value>\n" +
+                "<value field=\"pinposition2\">5</value><value field=\"pinpositionvalue2\"></value>\n" +
+                "<value field=\"pinposition3\">6</value><value field=\"pinpositionvalue3\"></value>\n" +
+                "</row></company-xmlext-query-ret>";
+        result.setResponseData(data, null);
+        result.setResponseHeaders("Header1: Value1\nHeader2: Value2");
+        result.setResponseCode("abcd");
+        result.setResponseMessage("The quick brown fox");
+        vars = new JMeterVariables();
+        jmctx.setVariables(vars);
+        jmctx.setPreviousResult(result);
+    }
+
+    @Test
+    public void testProcessAllElementsSingleMatch() {
+        vars.put("content", "one");
+        extractor.setMatchNumber(-1);
+        extractor.setRefName("varname");
+        extractor.setRegex("(\\w+)");
+        extractor.setScopeVariable("content");
+        extractor.setThreadContext(jmctx);
+        extractor.setTemplate("$1$");
+        extractor.process();
+        assertThat(vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
+        assertThat(vars.get("varname_1"), CoreMatchers.is("one"));
+        assertThat(vars.get("varname_matchNr"), CoreMatchers.is("1"));
+    }
+
+    @Test
+    public void testProcessAllElementsMultipleMatches() {
+        vars.put("content", "one, two");
+        extractor.setMatchNumber(-1);
+        extractor.setRefName("varname");
+        extractor.setRegex("(\\w+)");
+        extractor.setScopeVariable("content");
+        extractor.setThreadContext(jmctx);
+        extractor.setTemplate("$1$");
+        extractor.process();
+        assertThat(vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
+        assertThat(vars.get("varname_1"), CoreMatchers.is("one"));
+        assertThat(vars.get("varname_2"), CoreMatchers.is("two"));
+        assertThat(vars.get("varname_matchNr"), CoreMatchers.is("2"));
+    }
+
+    @Test
+    public void testEmptyDefaultVariable() {
+        extractor.setRegex("<value name=\"positioncount\">(.+?)</value>");
+        extractor.setTemplate("$1$");
+        extractor.setMatchNumber(1);
+        extractor.setDefaultEmptyValue(true);
+        extractor.process();
+        assertEquals("", vars.get("regVal"));
+    }
+
+    @Test
+    public void testNotEmptyDefaultVariable() {
+        extractor.setRegex("<value name=\"positioncount\">(.+?)</value>");
+        extractor.setTemplate("$1$");
+        extractor.setMatchNumber(1);
+        extractor.setDefaultEmptyValue(false);
+        extractor.process();
+        assertNull(vars.get("regVal"));
+    }
+
+    @Test
+    public void testVariableExtraction0() {
+        extractor.setRegex("<(value) field=\"");
+        extractor.setTemplate("$1$");
+        extractor.setMatchNumber(0);
+        extractor.process();
+        assertEquals("value", vars.get("regVal"));
+    }
 
     @Test
-    public void testScope1() throws Exception {
+    public void testVariableExtraction() {
+        extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
+        extractor.setTemplate("$2$");
+        extractor.setMatchNumber(2);
+        extractor.process();
+        assertEquals("5", vars.get("regVal"));
+        assertEquals("pinposition2", vars.get("regVal_g1"));
+        assertEquals("5", vars.get("regVal_g2"));
+        assertEquals("<value field=\"pinposition2\">5</value>", vars.get("regVal_g0"));
+        assertNull(vars.get("regVal_g3"));
+        assertEquals("2", vars.get("regVal_g"));
+    }
+
+    private static void templateSetup(RegexExtractor rex, String tmp) {
+        rex.setRegex("<company-(\\w+?)-(\\w+?)-(\\w+?)>");
+        rex.setMatchNumber(1);
+        rex.setTemplate(tmp);
+        rex.process();
+    }
+
+    @Test
+    public void testTemplate1() {
+        templateSetup(extractor, "");
+        assertEquals("<company-xmlext-query-ret>", vars.get("regVal_g0"));
+        assertEquals("xmlext", vars.get("regVal_g1"));
+        assertEquals("query", vars.get("regVal_g2"));
+        assertEquals("ret", vars.get("regVal_g3"));
+        assertEquals("", vars.get("regVal"));
+        assertEquals("3", vars.get("regVal_g"));
+    }
+
+    @Test
+    public void testTemplate2() {
+        templateSetup(extractor, "ABC");
+        assertEquals("ABC", vars.get("regVal"));
+    }
+
+    @Test
+    public void testTemplate3() {
+        templateSetup(extractor, "$2$");
+        assertEquals("query", vars.get("regVal"));
+    }
+
+    @Test
+    public void testTemplate4() {
+        templateSetup(extractor, "PRE$2$");
+        assertEquals("PREquery", vars.get("regVal"));
+    }
+
+    @Test
+    public void testTemplate5() {
+        templateSetup(extractor, "$2$POST");
+        assertEquals("queryPOST", vars.get("regVal"));
+    }
+
+    @Test
+    public void testTemplate6() {
+        templateSetup(extractor, "$2$$1$");
+        assertEquals("queryxmlext", vars.get("regVal"));
+    }
+
+    @Test
+    public void testTemplate7() {
+        templateSetup(extractor, "$2$MID$1$");
+        assertEquals("queryMIDxmlext", vars.get("regVal"));
+    }
+
+    @Test
+    public void testVariableExtraction2() {
+        extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
+        extractor.setTemplate("$1$");
+        extractor.setMatchNumber(3);
+        extractor.process();
+        assertEquals("pinposition3", vars.get("regVal"));
+    }
+
+    @Test
+    public void testVariableExtraction6() {
+        extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
+        extractor.setTemplate("$2$");
+        extractor.setMatchNumber(4);
+        extractor.setDefaultValue("default");
+        extractor.process();
+        assertEquals("default", vars.get("regVal"));
+    }
+
+    @Test
+    public void testVariableExtraction3() {
+        extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
+        extractor.setTemplate("_$1$");
+        extractor.setMatchNumber(2);
+        extractor.process();
+        assertEquals("_pinposition2", vars.get("regVal"));
+    }
+
+    @Test
+    public void testVariableExtraction5() {
+        extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
+        extractor.setTemplate("$1$");
+        extractor.setMatchNumber(1);// Set up the non-wild variables
+        extractor.process();
+        assertNotNull(vars.get("regVal"));
+        assertEquals("2", vars.get("regVal_g"));
+        assertNotNull(vars.get("regVal_g0"));
+        assertNotNull(vars.get("regVal_g1"));
+        assertNotNull(vars.get("regVal_g2"));
+
+        extractor.setMatchNumber(-1);
+        extractor.process();
+        assertNotNull(vars.get("regVal"));// Should not clear this?
+        assertNull(vars.get("regVal_g"));
+        assertNull(vars.get("regVal_g1"));
+        assertNull(vars.get("regVal_g2"));
+        assertEquals("3", vars.get("regVal_matchNr"));
+        assertEquals("pinposition1", vars.get("regVal_1"));
+        assertEquals("pinposition2", vars.get("regVal_2"));
+        assertEquals("pinposition3", vars.get("regVal_3"));
+        assertEquals("2", vars.get("regVal_1_g"));
+        assertEquals("pinposition1", vars.get("regVal_1_g1"));
+        assertEquals("1", vars.get("regVal_1_g2"));
+        assertEquals("6", vars.get("regVal_3_g2"));
+        assertEquals("<value field=\"pinposition1\">1</value>", vars.get("regVal_1_g0"));
+        assertNull(vars.get("regVal_4"));
+
+        // Check old values don't hang around:
+        extractor.setRegex("(\\w+)count"); // fewer matches
+        extractor.process();
+        assertEquals("2", vars.get("regVal_matchNr"));
+        assertEquals("position", vars.get("regVal_1"));
+        assertEquals("1", vars.get("regVal_1_g"));
+        assertEquals("position", vars.get("regVal_1_g1"));
+        assertNull("Unused variables should be null", vars.get("regVal_1_g2"));
+        assertEquals("invalidpin", vars.get("regVal_2"));
+        assertEquals("1", vars.get("regVal_2_g"));
+        assertEquals("invalidpin", vars.get("regVal_2_g1"));
+        assertNull("Unused variables should be null", vars.get("regVal_2_g2"));
+        assertEquals("1", vars.get("regVal_1_g"));
+        assertNull("Unused variables should be null", vars.get("regVal_3"));
+        assertNull("Unused variables should be null", vars.get("regVal_3_g"));
+        assertNull("Unused variables should be null", vars.get("regVal_3_g0"));
+        assertNull("Unused variables should be null", vars.get("regVal_3_g1"));
+        assertNull("Unused variables should be null", vars.get("regVal_3_g2"));
+
+        // Check when match fails
+        extractor.setRegex("xxxx(.)(.)");
+        extractor.process();
+        assertEquals("0", vars.get("regVal_matchNr"));
+        assertNull("Unused variables should be null", vars.get("regVal_1"));
+        assertNull("Unused variables should be null", vars.get("regVal_1_g0"));
+        assertNull("Unused variables should be null", vars.get("regVal_1_g1"));
+        assertNull("Unused variables should be null", vars.get("regVal_1_g2"));
+    }
+
+    @Test
+    public void testVariableExtraction7() {
+        extractor.setRegex("Header1: (\\S+)");
+        extractor.setTemplate("$1$");
+        extractor.setMatchNumber(1);
+        assertTrue("useBody should be true", extractor.useBody());
+        assertFalse("useHdrs should be false", extractor.useHeaders());
+        assertFalse("useURL should be false", extractor.useUrl());
+        extractor.setUseField(RegexExtractor.USE_BODY);
+        assertTrue("useBody should be true", extractor.useBody());
+        assertFalse("useHdrs should be false", extractor.useHeaders());
+        assertFalse("useURL should be false", extractor.useUrl());
+        extractor.setUseField(RegexExtractor.USE_HDRS);
+        assertTrue("useHdrs should be true", extractor.useHeaders());
+        assertFalse("useBody should be false", extractor.useBody());
+        assertFalse("useURL should be false", extractor.useUrl());
+        extractor.process();
+        assertEquals("Value1", vars.get("regVal"));
+        extractor.setUseField(RegexExtractor.USE_URL);
+        assertFalse("useHdrs should be false", extractor.useHeaders());
+        assertFalse("useBody should be false", extractor.useBody());
+        assertTrue("useURL should be true", extractor.useUrl());
+    }
+
+    @Test
+    public void testVariableExtraction8() throws Exception {
+        extractor.setRegex("http://jakarta\\.apache\\.org/(\\w+)");
+        extractor.setTemplate("$1$");
+        extractor.setMatchNumber(1);
+        extractor.setUseField(RegexExtractor.USE_URL);
+        assertFalse("useHdrs should be false", extractor.useHeaders());
+        assertFalse("useBody should be false", extractor.useBody());
+        assertTrue("useURL should be true", extractor.useUrl());
+        extractor.process();
+        assertNull(vars.get("regVal"));
+        result.setURL(new URL("http://jakarta.apache.org/index.html?abcd"));
+        extractor.process();
+        assertEquals("index", vars.get("regVal"));
+    }
+
+    @Test
+    public void testVariableExtraction9() {
+        extractor.setRegex("(\\w+)");
+        extractor.setTemplate("$1$");
+        extractor.setMatchNumber(1);
+        extractor.setUseField(RegexExtractor.USE_CODE);
+        assertFalse("useHdrs should be false", extractor.useHeaders());
+        assertFalse("useBody should be false", extractor.useBody());
+        assertFalse("useURL should be false", extractor.useUrl());
+        assertFalse("useMessage should be false", extractor.useMessage());
+        assertTrue("useCode should be true", extractor.useCode());
+        extractor.process();
+        assertEquals("abcd", vars.get("regVal"));
+        extractor.setUseField(RegexExtractor.USE_MESSAGE);
+        assertFalse("useHdrs should be false", extractor.useHeaders());
+        assertFalse("useBody should be false", extractor.useBody());
+        assertFalse("useURL should be false", extractor.useUrl());
+        assertTrue("useMessage should be true", extractor.useMessage());
+        assertFalse("useCode should be false", extractor.useCode());
+        extractor.setMatchNumber(3);
+        extractor.process();
+        assertEquals("brown", vars.get("regVal"));
+    }
+
+    @Test
+    public void testNoDefault() {
+        extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
+        extractor.setTemplate("$2$");
+        extractor.setMatchNumber(4);
+        vars.put("regVal", "initial");
+        assertEquals("initial", vars.get("regVal"));
+        extractor.process();
+        assertEquals("initial", vars.get("regVal"));
+    }
+
+    @Test
+    public void testDefault() {
+        extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
+        extractor.setTemplate("$2$");
+        extractor.setMatchNumber(999);
+        extractor.setDefaultValue("default");
+        vars.put("regVal", "initial");
+        assertEquals("initial", vars.get("regVal"));
+        extractor.process();
+        assertEquals("default", vars.get("regVal"));
+        assertNull(vars.get("regVal_g0"));
+        assertNull(vars.get("regVal_g1"));
+    }
+
+    @Test
+    public void testStaleVariables() {
+        extractor.setRegex("<value field=\"(pinposition\\d+)\">(\\d+)</value>");
+        extractor.setTemplate("$2$");
+        extractor.setMatchNumber(1);
+        extractor.setDefaultValue("default");
+        extractor.process();
+        assertEquals("1", vars.get("regVal"));
+        assertEquals("1", vars.get("regVal_g2"));
+        assertEquals("2", vars.get("regVal_g"));
+        assertNotNull(vars.get("regVal_g0"));
+        assertNotNull(vars.get("regVal_g1"));
+        // Now rerun with match fail
+        extractor.setMatchNumber(10);
+        extractor.process();
+        assertEquals("default", vars.get("regVal"));
+        assertNull(vars.get("regVal_g0"));
+        assertNull(vars.get("regVal_g1"));
+        assertNull(vars.get("regVal_g"));
+    }
+
+    @Test
+    public void testScope1() {
         result.setResponseData("<title>ONE</title>", "ISO-8859-1");
         extractor.setScopeParent();
         extractor.setTemplate("$1$");
@@ -413,7 +410,7 @@ public class TestRegexExtractor {
     }
 
     @Test
-    public void testScope2() throws Exception {
+    public void testScope2() {
         result.sampleStart();
         result.setResponseData("<title>PARENT</title>", "ISO-8859-1");
         result.sampleEnd();
@@ -484,5 +481,4 @@ public class TestRegexExtractor {
         final String found = vars.get("regVal");
         assertTrue(found.equals("ONE") || found.equals("TWO"));
     }
-
 }
diff --git a/src/core/src/main/java/org/apache/jmeter/report/dashboard/AbstractDataExporter.java b/src/core/src/main/java/org/apache/jmeter/report/dashboard/AbstractDataExporter.java
index 7625b5f..e0ea757 100644
--- a/src/core/src/main/java/org/apache/jmeter/report/dashboard/AbstractDataExporter.java
+++ b/src/core/src/main/java/org/apache/jmeter/report/dashboard/AbstractDataExporter.java
@@ -32,9 +32,7 @@ public abstract class AbstractDataExporter implements DataExporter {
 
     private String name;
 
-    /**
-     * Instantiates a new abstract data exporter.
-     */
+    /** Instantiates a new abstract data exporter. */
     protected AbstractDataExporter() {
     }
 
@@ -52,8 +50,7 @@ public abstract class AbstractDataExporter implements DataExporter {
      *            type of value to be found
      * @return the value matching the data name
      */
-    protected static <T> T findValue(Class<T> clazz, String data,
-            ResultData root) {
+    protected static <T> T findValue(Class<T> clazz, String data, ResultData root) {
         T value = null;
         ResultData result = findData(data, root);
         if (result instanceof ValueResultData) {
@@ -77,23 +74,23 @@ public abstract class AbstractDataExporter implements DataExporter {
      * @return the ResultData matching the data name
      */
     protected static ResultData findData(String data, ResultData root) {
-        ResultData result = null;
         String[] pathItems = StringUtils.split(data, '.');
-        if (pathItems != null) {
-            if (root instanceof MapResultData) {
-                int count = pathItems.length;
-                int index = 0;
-                MapResultData map = (MapResultData) root;
-                while (index < count && result == null) {
-                    ResultData current = map.getResult(pathItems[index]);
-                    if (index == count - 1) {
-                        result = current;
-                    } else {
-                        if (current instanceof MapResultData) {
-                            map = (MapResultData) current;
-                            index++;
-                        }
-                    }
+        if (pathItems == null || !(root instanceof MapResultData)) {
+            return null;
+        }
+
+        ResultData result = null;
+        int count = pathItems.length;
+        int index = 0;
+        MapResultData map = (MapResultData) root;
+        while (index < count && result == null) {
+            ResultData current = map.getResult(pathItems[index]);
+            if (index == count - 1) {
+                result = current;
+            } else {
+                if (current instanceof MapResultData) {
+                    map = (MapResultData) current;
+                    index++;
                 }
             }
         }
@@ -121,9 +118,9 @@ public abstract class AbstractDataExporter implements DataExporter {
         this.name = name;
     }
 
-    protected <TProperty> TProperty getPropertyFromConfig(SubConfiguration cfg,
-            String property, TProperty defaultValue, Class<TProperty> clazz)
-                    throws ExportException {
+    protected <TProperty> TProperty getPropertyFromConfig(
+            SubConfiguration cfg, String property, TProperty defaultValue, Class<TProperty> clazz)
+            throws ExportException {
         try {
             return cfg.getProperty(property, defaultValue, clazz);
         } catch (ConfigurationException ex) {
diff --git a/src/core/src/main/java/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java b/src/core/src/main/java/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java
index acd8515..0512954 100644
--- a/src/core/src/main/java/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java
+++ b/src/core/src/main/java/org/apache/jmeter/report/dashboard/HtmlTemplateExporter.java
@@ -18,7 +18,6 @@
 package org.apache.jmeter.report.dashboard;
 
 import java.io.File;
-import java.io.FileFilter;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.util.HashMap;
@@ -60,13 +59,6 @@ import freemarker.template.TemplateExceptionHandler;
  * @since 3.0
  */
 public class HtmlTemplateExporter extends AbstractDataExporter {
-    private static final FileFilter HTML_REPORT_FILE_FILTER =
-        file ->
-            (file.isFile() &&
-                    "index.html".equals(file.getName()))
-                    || (file.isDirectory() &&
-                            ("content".equals(file.getName()) ||
-                                    file.getName().startsWith("sbadmin2-")));
     private static final String CUSTOM_GRAPH_PREFIX = "custom_";
 
     /** Format used for non null check of parameters. */
@@ -114,7 +106,6 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
 
     /**
      * This class allows to customize data before exporting them
-     *
      */
     private interface ResultCustomizer {
         ResultData customizeResult(ResultData result);
@@ -122,7 +113,6 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
 
     /**
      * This class allows to inject graph_options properties to the exported data
-     *
      */
     private static class ExtraOptionsResultCustomizer implements ResultCustomizer {
         private SubConfiguration extraOptions;
@@ -147,32 +137,26 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
         public ResultData customizeResult(ResultData result) {
             MapResultData customizedResult = new MapResultData();
             customizedResult.setResult(DATA_CTX_RESULT, result);
-            if (extraOptions != null) {
-                MapResultData extraResult = new MapResultData();
-                for (Map.Entry<String, String> extraEntry : extraOptions
-                        .getProperties().entrySet()) {
-                    extraResult.setResult(extraEntry.getKey(),
-                            new ValueResultData(extraEntry.getValue()));
-                }
-                customizedResult.setResult(DATA_CTX_EXTRA_OPTIONS, extraResult);
+
+            if (extraOptions == null) {
+                return customizedResult;
             }
+
+            MapResultData extraResult = new MapResultData();
+            extraOptions.getProperties().forEach((key, value) ->
+                    extraResult.setResult(key, new ValueResultData(value)));
+            customizedResult.setResult(DATA_CTX_EXTRA_OPTIONS, extraResult);
+
             return customizedResult;
         }
-
     }
 
-    /**
-     * This class allows to check exported data
-     *
-     */
+    /** This class allows to check exported data */
     private interface ResultChecker {
         boolean checkResult(DataContext dataContext, ResultData result);
     }
 
-    /**
-     * This class allows to detect empty graphs
-     *
-     */
+    /** This class allows to detect empty graphs */
     private static class EmptyGraphChecker implements ResultChecker {
 
         private final boolean filtersOnlySampleSeries;
@@ -204,140 +188,104 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
             this.filterPattern = filterPattern;
         }
 
-        /*
-         * (non-Javadoc)
-         *
-         * @see
-         * org.apache.jmeter.report.dashboard.HtmlTemplateExporter.ResultChecker
-         * #checkResult( org.apache.jmeter.report.core.DataContext dataContext, org.apache.jmeter.report.processor.ResultData)
-         */
+        /** @see ResultChecker#checkResult(DataContext, ResultData) */
         @Override
         public boolean checkResult(DataContext dataContext, ResultData result) {
-            Boolean supportsControllerDiscrimination = findValue(Boolean.class,
+            boolean supportsControllerDiscrimination = findValue(Boolean.class,
                     AbstractGraphConsumer.RESULT_SUPPORTS_CONTROLLERS_DISCRIMINATION,
-                    result);
+                    result).booleanValue();
 
-            if (supportsControllerDiscrimination.booleanValue() && showControllerSeriesOnly
+            if (supportsControllerDiscrimination
+                    && showControllerSeriesOnly
                     && excludesControllers) {
                 // Exporter shows controller series only
                 // whereas the current graph support controller
-                // discrimination and excludes
-                // controllers
+                // discrimination and excludes controllers
                 log.warn("{} is set while the graph {} excludes controllers.",
                         ReportGeneratorConfiguration.EXPORTER_KEY_SHOW_CONTROLLERS_ONLY, graphId);
                 return false;
-            } else {
-                if (filterPattern != null) {
-                    // Detect whether none series matches
-                    // the series filter.
-                    ResultData seriesResult = findData(
-                            AbstractGraphConsumer.RESULT_SERIES, result);
-                    if (seriesResult instanceof ListResultData) {
-
-                        // Try to find at least one pattern matching
-                        ListResultData seriesList = (ListResultData) seriesResult;
-                        int count = seriesList.getSize();
-                        int index = 0;
-                        boolean matches = false;
-                        while (index < count && !matches) {
-                            ResultData currentResult = seriesList.get(index);
-                            if (currentResult instanceof MapResultData) {
-                                MapResultData seriesData = (MapResultData) currentResult;
-                                String name = findValue(String.class,
-                                        AbstractGraphConsumer.RESULT_SERIES_NAME,
-                                        seriesData);
-
-                                // Is the current series a controller series ?
-                                boolean isController = findValue(Boolean.class,
-                                        AbstractGraphConsumer.RESULT_SERIES_IS_CONTROLLER,
-                                        seriesData).booleanValue();
-
-                                matches = filterPattern.matcher(name).matches();
-                                if (matches) {
-                                    // If the name matches pattern, other
-                                    // properties can discard the series
-                                    matches = !filtersOnlySampleSeries
-                                            || !supportsControllerDiscrimination.booleanValue()
-                                            || isController
-                                            || !showControllerSeriesOnly;
-                                    if(log.isDebugEnabled()) {
-                                        log.debug(
-                                                "name:{} matches pattern:{}, supportsControllerDiscrimination:{}, "
-                                                + "isController:{}, showControllerSeriesOnly:{}",
-                                                name, filterPattern.pattern(),
-                                                supportsControllerDiscrimination,
-                                                isController,
-                                                showControllerSeriesOnly);
-                                    }
-                                } else {
-                                    // If the name does not match the pattern,
-                                    // other properties can hold the series
-                                    matches = filtersOnlySampleSeries
-                                            && !supportsControllerDiscrimination.booleanValue();
-                                    if(log.isDebugEnabled()) {
-                                        log.debug("name:{} does not match pattern:{}, filtersOnlySampleSeries:{},"
-                                            + " supportsControllerDiscrimination:{}",
-                                            name, filterPattern.pattern(),
-                                            filtersOnlySampleSeries,
-                                            supportsControllerDiscrimination);
-                                    }
-                                }
-                            }
-                            index++;
+            }
+
+            if (filterPattern == null) {
+                return true;
+            }
+
+            // Detect whether none series matches the series filter.
+            ResultData seriesResult = findData(AbstractGraphConsumer.RESULT_SERIES, result);
+            if (!(seriesResult instanceof ListResultData)) {
+                return true;
+            }
+
+            // Try to find at least one pattern matching
+            ListResultData seriesList = (ListResultData) seriesResult;
+            int count = seriesList.getSize();
+            int index = 0;
+            boolean matches = false;
+            while (index < count && !matches) {
+                ResultData currentResult = seriesList.get(index);
+                if (currentResult instanceof MapResultData) {
+                    MapResultData seriesData = (MapResultData) currentResult;
+                    String name = findValue(String.class,
+                            AbstractGraphConsumer.RESULT_SERIES_NAME,
+                            seriesData);
+
+                    // Is the current series a controller series ?
+                    boolean isController = findValue(Boolean.class,
+                            AbstractGraphConsumer.RESULT_SERIES_IS_CONTROLLER,
+                            seriesData).booleanValue();
+
+                    matches = filterPattern.matcher(name).matches();
+                    if (matches) {
+                        // If the name matches pattern, other
+                        // properties can discard the series
+                        matches = !filtersOnlySampleSeries
+                                || !supportsControllerDiscrimination
+                                || isController
+                                || !showControllerSeriesOnly;
+                        if(log.isDebugEnabled()) {
+                            log.debug(
+                                    "name:{} matches pattern:{}, supportsControllerDiscrimination:{}, "
+                                    + "isController:{}, showControllerSeriesOnly:{}",
+                                    name, filterPattern.pattern(),
+                                    supportsControllerDiscrimination,
+                                    isController,
+                                    showControllerSeriesOnly);
                         }
-                        if (!matches) {
-                            // None series matches the pattern
-                            log.warn("No serie matches the series_filter: {} in graph: {}",
-                                    ReportGeneratorConfiguration.EXPORTER_KEY_SERIES_FILTER, graphId);
-                            return false;
+                    } else {
+                        // If the name does not match the pattern,
+                        // other properties can hold the series
+                        matches = filtersOnlySampleSeries
+                                && !supportsControllerDiscrimination;
+                        if (log.isDebugEnabled()) {
+                            log.debug("name:{} does not match pattern:{}, filtersOnlySampleSeries:{},"
+                                + " supportsControllerDiscrimination:{}",
+                                name, filterPattern.pattern(),
+                                filtersOnlySampleSeries,
+                                supportsControllerDiscrimination);
                         }
                     }
                 }
+                index++;
+            }
+            if (!matches) {
+                log.warn("No series matches the series_filter: {} in graph: {}",
+                        ReportGeneratorConfiguration.EXPORTER_KEY_SERIES_FILTER, graphId);
+                return false;
             }
             return true;
         }
     }
 
-    private <TVisit> void addResultToContext(String resultKey,
-            Map<String, Object> storage, DataContext dataContext,
-            ResultDataVisitor<TVisit> visitor) {
-        addResultToContext(resultKey, storage, dataContext, visitor, null,
-                null);
-    }
-
-    private <TVisit> void addResultToContext(String resultKey,
-            Map<String, Object> storage, DataContext dataContext,
-            ResultDataVisitor<TVisit> visitor, ResultCustomizer customizer,
-            ResultChecker checker) {
-        Object data = storage.get(resultKey);
-        if (data instanceof ResultData) {
-            ResultData result = (ResultData) data;
-            if (checker != null) {
-                checker.checkResult(dataContext, result);
-            }
-            if (customizer != null) {
-                result = customizer.customizeResult(result);
-            }
-            dataContext.put(resultKey, result.accept(visitor));
-        }
-    }
+    private boolean htmlReportFileFilter(File file) {
+        String fileName = file.getName();
+        boolean isIndexHtmlFile = file.isFile() && fileName.equals("index.html");
+        boolean isContentOrAdmin = fileName.equals("content") || fileName.startsWith("sbadmin2-");
 
-    private long formatTimestamp(String key, DataContext context) {
-        // FIXME Why convert to double then long (rounding ?)
-        double result = Double.parseDouble((String) context.get(key));
-        long timestamp = (long) result;
-        // Quote the string to respect Json spec.
-        context.put(key, '"' + TimeHelper.formatTimeStamp(timestamp) + '"');
-        return timestamp;
+        return isIndexHtmlFile || (file.isDirectory() && isContentOrAdmin);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.apache.jmeter.report.dashboard.DataExporter#Export(org.apache.jmeter
-     * .report.processor.SampleContext,
-     * org.apache.jmeter.report.config.ReportGeneratorConfiguration)
+    /**
+     * @see DataExporter#export(SampleContext, File, ReportGeneratorConfiguration)
      */
     @Override
     public void export(SampleContext context, File file,
@@ -352,14 +300,18 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
         DataContext dataContext = new DataContext();
 
         // Get the configuration of the current exporter
-        final ExporterConfiguration exportCfg = configuration
-                .getExportConfigurations().get(getName());
+        final ExporterConfiguration exportCfg =
+                configuration.getExportConfigurations().get(getName());
 
         // Get template directory property value
-        File templateDirectory = getPropertyFromConfig(exportCfg, TEMPLATE_DIR,
-                new File(JMeterUtils.getJMeterBinDir(), TEMPLATE_DIR_NAME_DEFAULT), File.class);
+        File templateDirectory = getPropertyFromConfig(
+                exportCfg,
+                TEMPLATE_DIR,
+                new File(JMeterUtils.getJMeterBinDir(), TEMPLATE_DIR_NAME_DEFAULT),
+                File.class);
         if (!templateDirectory.isDirectory()) {
-            String message = String.format(INVALID_TEMPLATE_DIRECTORY_FMT,
+            String message = String.format(
+                    INVALID_TEMPLATE_DIRECTORY_FMT,
                     templateDirectory.getAbsolutePath());
             log.error(message);
             throw new ExportException(message);
@@ -373,18 +325,18 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
             outputDir = new File(globallyDefinedOutputDir);
         }
 
-        JOrphanUtils.canSafelyWriteToFolder(outputDir, HTML_REPORT_FILE_FILTER);
+        JOrphanUtils.canSafelyWriteToFolder(outputDir, this::htmlReportFileFilter);
 
         if (log.isInfoEnabled()) {
             log.info("Will generate dashboard in folder: {}", outputDir.getAbsolutePath());
         }
 
-        // Add the flag defining whether only sample series are filtered to the
-        // context
-        final boolean filtersOnlySampleSeries = exportCfg
-                .filtersOnlySampleSeries();
-        addToContext(DATA_CTX_FILTERS_ONLY_SAMPLE_SERIES,
-                Boolean.valueOf(filtersOnlySampleSeries), dataContext);
+        // Add a flag defining if only sample series are filtered to the context
+        final boolean filtersOnlySampleSeries = exportCfg.filtersOnlySampleSeries();
+        addToContext(
+                DATA_CTX_FILTERS_ONLY_SAMPLE_SERIES,
+                Boolean.valueOf(filtersOnlySampleSeries),
+                dataContext);
 
         // Add the series filter to the context
         final String seriesFilter = exportCfg.getSeriesFilter();
@@ -399,76 +351,73 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
         addToContext(DATA_CTX_SERIES_FILTER, seriesFilter, dataContext);
 
         // Add the flag defining whether only controller series are displayed
-        final boolean showControllerSeriesOnly = exportCfg
-                .showControllerSeriesOnly();
-        addToContext(DATA_CTX_SHOW_CONTROLLERS_ONLY,
-                Boolean.valueOf(showControllerSeriesOnly), dataContext);
+        final boolean showControllerSeriesOnly = exportCfg.showControllerSeriesOnly();
+        addToContext(
+                DATA_CTX_SHOW_CONTROLLERS_ONLY,
+                Boolean.valueOf(showControllerSeriesOnly),
+                dataContext);
 
         JsonizerVisitor jsonizer = new JsonizerVisitor();
         Map<String, Object> storedData = context.getData();
 
         // Add begin date consumer result to the data context
-        addResultToContext(ReportGenerator.BEGIN_DATE_CONSUMER_NAME, storedData,
-                dataContext, jsonizer);
+        addResultToContext(
+                ReportGenerator.BEGIN_DATE_CONSUMER_NAME, storedData, dataContext, jsonizer);
 
         // Add end date summary consumer result to the data context
-        addResultToContext(ReportGenerator.END_DATE_CONSUMER_NAME, storedData,
-                dataContext, jsonizer);
+        addResultToContext(
+                ReportGenerator.END_DATE_CONSUMER_NAME, storedData, dataContext, jsonizer);
 
         // Add Apdex summary consumer result to the data context
-        addResultToContext(ReportGenerator.APDEX_SUMMARY_CONSUMER_NAME,
-                storedData, dataContext, jsonizer);
+        addResultToContext(
+                ReportGenerator.APDEX_SUMMARY_CONSUMER_NAME, storedData, dataContext, jsonizer);
 
         // Add errors summary consumer result to the data context
-        addResultToContext(ReportGenerator.ERRORS_SUMMARY_CONSUMER_NAME,
-                storedData, dataContext, jsonizer);
+        addResultToContext(
+                ReportGenerator.ERRORS_SUMMARY_CONSUMER_NAME, storedData, dataContext, jsonizer);
 
         // Add requests summary consumer result to the data context
-        addResultToContext(ReportGenerator.REQUESTS_SUMMARY_CONSUMER_NAME,
-                storedData, dataContext, jsonizer);
+        addResultToContext(
+                ReportGenerator.REQUESTS_SUMMARY_CONSUMER_NAME, storedData, dataContext, jsonizer);
 
         // Add statistics summary consumer result to the data context
-        addResultToContext(ReportGenerator.STATISTICS_SUMMARY_CONSUMER_NAME,
-                storedData, dataContext, jsonizer);
+        addResultToContext(
+                ReportGenerator.STATISTICS_SUMMARY_CONSUMER_NAME, storedData, dataContext, jsonizer);
 
         // Add Top 5 errors by sampler consumer result to the data context
-        addResultToContext(ReportGenerator.TOP5_ERRORS_BY_SAMPLER_CONSUMER_NAME,
-                storedData, dataContext, jsonizer);
+        addResultToContext(
+                ReportGenerator.TOP5_ERRORS_BY_SAMPLER_CONSUMER_NAME, storedData, dataContext, jsonizer);
 
         // Collect graph results from sample context and transform them into
         // Json strings to inject in the data context
         ExtraOptionsResultCustomizer customizer = new ExtraOptionsResultCustomizer();
-        EmptyGraphChecker checker = new EmptyGraphChecker(
-                filtersOnlySampleSeries, showControllerSeriesOnly,
-                filterPattern);
-        DataContext customGraphs = new DataContext();
+        EmptyGraphChecker checker =
+                new EmptyGraphChecker(filtersOnlySampleSeries, showControllerSeriesOnly, filterPattern);
         Map<String, GraphConfiguration> mapConfiguration = new HashMap<>();
-        for (Map.Entry<String, GraphConfiguration> graphEntry : configuration
-                .getGraphConfigurations().entrySet()) {
+        DataContext customGraphs = new DataContext();
+
+        for (Map.Entry<String, GraphConfiguration> graphEntry : configuration.getGraphConfigurations().entrySet()) {
             final String graphId = graphEntry.getKey();
             final GraphConfiguration graphConfiguration = graphEntry.getValue();
-            final SubConfiguration extraOptions = exportCfg.getGraphExtraConfigurations().get(graphId);
 
             // Initialize customizer and checker
-            customizer.setExtraOptions(extraOptions);
-            checker.setExcludesControllers(
-                    graphConfiguration.excludesControllers());
+            customizer.setExtraOptions(exportCfg.getGraphExtraConfigurations().get(graphId));
+            checker.setExcludesControllers(graphConfiguration.excludesControllers());
             checker.setGraphId(graphId);
             mapConfiguration.put(graphId, graphConfiguration);
-            if(graphId.startsWith(CUSTOM_GRAPH_PREFIX)) {
-                addResultToContext(graphId, storedData, customGraphs, jsonizer,
-                        customizer, checker);
+            if (graphId.startsWith(CUSTOM_GRAPH_PREFIX)) {
+                addResultToContext(
+                        graphId, storedData, customGraphs, jsonizer, customizer, checker);
             } else {
                 // Export graph data
-                addResultToContext(graphId, storedData, dataContext, jsonizer,
-                    customizer, checker);
+                addResultToContext(
+                        graphId, storedData, dataContext, jsonizer, customizer, checker);
             }
         }
         dataContext.put("graphConfigurations", mapConfiguration);
         dataContext.put("customsGraphsData", customGraphs);
 
-        // Replace the begin date with its formatted string and store the old
-        // timestamp
+        // Replace the begin date with its formatted string and store the old timestamp
         long oldTimestamp = formatTimestamp(
                 ReportGenerator.BEGIN_DATE_CONSUMER_NAME, dataContext);
 
@@ -477,11 +426,13 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
 
         // Add time zone offset (that matches the begin date) to the context
         TimeZone timezone = TimeZone.getDefault();
-        addToContext(DATA_CTX_TIMEZONE_OFFSET,
-                Integer.valueOf(timezone.getOffset(oldTimestamp)), dataContext);
+        addToContext(
+                DATA_CTX_TIMEZONE_OFFSET,
+                Integer.valueOf(timezone.getOffset(oldTimestamp)),
+                dataContext);
 
         // Add report title to the context
-        if(!StringUtils.isEmpty(configuration.getReportTitle())) {
+        if (StringUtils.isNotEmpty(configuration.getReportTitle())) {
             dataContext.put(DATA_CTX_REPORT_TITLE, StringEscapeUtils.escapeHtml4(configuration.getReportTitle()));
         }
 
@@ -489,22 +440,21 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
         addToContext(DATA_CTX_TESTFILE, file.getName(), dataContext);
 
         // Add the overall filter property to the context
-        addToContext(DATA_CTX_OVERALL_FILTER, configuration.getSampleFilter(),
-                dataContext);
+        addToContext(DATA_CTX_OVERALL_FILTER, configuration.getSampleFilter(), dataContext);
 
         // Walk template directory to copy files and process templated ones
-        Configuration templateCfg = new Configuration(
-                Configuration.getVersion());
+        Configuration templateCfg = new Configuration(Configuration.getVersion());
         try {
             templateCfg.setDirectoryForTemplateLoading(templateDirectory);
-            templateCfg.setTemplateExceptionHandler(
-                    TemplateExceptionHandler.RETHROW_HANDLER);
+            templateCfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
             if (log.isInfoEnabled()) {
                 log.info("Report will be generated in: {}, creating folder structure", outputDir.getAbsolutePath());
             }
             FileUtils.forceMkdir(outputDir);
             TemplateVisitor visitor = new TemplateVisitor(
-                    templateDirectory.toPath(), outputDir.toPath(), templateCfg,
+                    templateDirectory.toPath(),
+                    outputDir.toPath(),
+                    templateCfg,
                     dataContext);
             Files.walkFileTree(templateDirectory.toPath(), visitor);
         } catch (IOException ex) {
@@ -512,6 +462,36 @@ public class HtmlTemplateExporter extends AbstractDataExporter {
         }
 
         log.debug("End of template processing");
+    }
 
+    private <TVisit> void addResultToContext(
+            String resultKey, Map<String, Object> storage,
+            DataContext dataContext, ResultDataVisitor<TVisit> visitor) {
+        addResultToContext(resultKey, storage, dataContext, visitor, null, null);
+    }
+
+    private <TVisit> void addResultToContext(
+            String resultKey, Map<String, Object> storage, DataContext dataContext,
+            ResultDataVisitor<TVisit> visitor, ResultCustomizer customizer, ResultChecker checker) {
+        Object data = storage.get(resultKey);
+        if (data instanceof ResultData) {
+            ResultData result = (ResultData) data;
+            if (checker != null) {
+                checker.checkResult(dataContext, result);
+            }
+            if (customizer != null) {
+                result = customizer.customizeResult(result);
+            }
+            dataContext.put(resultKey, result.accept(visitor));
+        }
+    }
+
+    private long formatTimestamp(String key, DataContext context) {
+        // FIXME Why convert to double then long (rounding ?)
+        double result = Double.parseDouble((String) context.get(key));
+        long timestamp = (long) result;
+        // Quote the string to respect Json spec.
+        context.put(key, '"' + TimeHelper.formatTimeStamp(timestamp) + '"');
+        return timestamp;
     }
 }
diff --git a/src/jorphan/src/main/java/org/apache/commons/cli/avalon/CLOption.java b/src/jorphan/src/main/java/org/apache/commons/cli/avalon/CLOption.java
index 0a1ef9a..c2bba64 100644
--- a/src/jorphan/src/main/java/org/apache/commons/cli/avalon/CLOption.java
+++ b/src/jorphan/src/main/java/org/apache/commons/cli/avalon/CLOption.java
@@ -58,7 +58,7 @@ public final class CLOption {
      * @return the argument
      */
     public final String getArgument(final int index) {
-        if (null == this.arguments || index < 0 || index >= this.arguments.length) {
+        if (this.arguments == null || index < 0 || index >= this.arguments.length) {
             return null;
         } else {
             return this.arguments[index];


Mime
View raw message