You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2022/07/09 12:49:01 UTC

[jmeter] branch master updated: Make failing tests run again and add more tests

This is an automated email from the ASF dual-hosted git repository.

fschumacher 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 157db3679a Make failing tests run again and add more tests
157db3679a is described below

commit 157db3679a5ed14e97f4b7dd59f29b395217cd48
Author: Felix Schumacher <fe...@internetallee.de>
AuthorDate: Sat Jul 9 14:48:17 2022 +0200

    Make failing tests run again and add more tests
    
    Bugzilla Id: 66140
---
 .../apache/jmeter/report/core/SampleMetaDataParser.java   |  5 +++--
 .../jmeter/report/core/SampleMetadataParserSpec.groovy    | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/report/core/SampleMetaDataParser.java b/src/core/src/main/java/org/apache/jmeter/report/core/SampleMetaDataParser.java
index be00c516b5..b798656efd 100644
--- a/src/core/src/main/java/org/apache/jmeter/report/core/SampleMetaDataParser.java
+++ b/src/core/src/main/java/org/apache/jmeter/report/core/SampleMetaDataParser.java
@@ -39,9 +39,10 @@ public class SampleMetaDataParser {
             // word followed by 0 or more repeats of (non-word char + word)
             // where the non-word char (\2) is the same
             // e.g. abc|def|ghi but not abd|def~ghi
-            .compile("\\w+((\\W)\\w+)?(\\2\\w+)*(\\2\"\\w+\")*" // $NON-NLS-1$
+            .compile("\\w+((\\W)[\\w ]+)?(\\2[\\w ]+)*(\\2\"[\\w ]+\")*" // $NON-NLS-1$
                     // last entries may be quoted strings
             );
+    private static final Pattern ALL_WORD_CHARS = Pattern.compile("^\\w+$");
 
     public SampleMetaDataParser(char separator) {
         this.separator = separator;
@@ -49,7 +50,7 @@ public class SampleMetaDataParser {
 
     public SampleMetadata parse(String headRow) {
         char useSep = separator;
-        if (headRow.indexOf(useSep) < 0) {
+        if (headRow.indexOf(useSep) < 0 && !ALL_WORD_CHARS.matcher(headRow).matches()) {
             Matcher matcher = DELIMITER_PATTERN.matcher(headRow);
             if (matcher.matches()) {
                 String guessedSep = matcher.group(2);
diff --git a/src/core/src/test/groovy/org/apache/jmeter/report/core/SampleMetadataParserSpec.groovy b/src/core/src/test/groovy/org/apache/jmeter/report/core/SampleMetadataParserSpec.groovy
index 180fce0d7d..fe1ed72413 100644
--- a/src/core/src/test/groovy/org/apache/jmeter/report/core/SampleMetadataParserSpec.groovy
+++ b/src/core/src/test/groovy/org/apache/jmeter/report/core/SampleMetadataParserSpec.groovy
@@ -40,4 +40,19 @@ class SampleMetadataParserSpec extends Specification {
             ','       | "abcdef"          | ["abcdef"]
     }
 
+    def "Parse headers (#headers) with wrong separator (#separator) and get (#expectedColumns)"() {
+        given:
+        def sut = new SampleMetaDataParser(separator as char)
+        when:
+        def columns = sut.parse(headers).columns
+        then:
+        columns == expectedColumns
+        where:
+        separator | headers           | expectedColumns
+        ','       | "a;b;c;d;e"       | ["a", "b", "c", "d", "e"]
+        ','       | "a|b|c|d|e"       | ["a", "b", "c", "d", "e"]
+        ','       | "aa|bb|cc|dd|eef" | ["aa", "bb", "cc", "dd", "eef"]
+        ','       | "a&b&c&d&e"       | ["a", "b", "c", "d", "e"]
+        ','       | "a\tb c\td\te"    | ["a", "b c", "d", "e"]
+    }
 }