You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2019/10/03 11:57:16 UTC

[jmeter] branch master updated: Bug 63775

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 e9a895f  Bug 63775
e9a895f is described below

commit e9a895f2f114d5117a38d173e2d2c90f9806a134
Author: pmouawad <p....@ubik-ingenierie.com>
AuthorDate: Thu Oct 3 13:57:12 2019 +0200

    Bug 63775
    
    Switch to JUnit 5
    Add some tests
    Clarify docs
---
 .../jmeter/extractor/TestBoundaryExtractor.java    | 42 ++++++++++++++--------
 xdocs/usermanual/component_reference.xml           |  1 +
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/src/components/src/test/java/org/apache/jmeter/extractor/TestBoundaryExtractor.java b/src/components/src/test/java/org/apache/jmeter/extractor/TestBoundaryExtractor.java
index a5d16ac..1c79e15 100644
--- a/src/components/src/test/java/org/apache/jmeter/extractor/TestBoundaryExtractor.java
+++ b/src/components/src/test/java/org/apache/jmeter/extractor/TestBoundaryExtractor.java
@@ -18,15 +18,16 @@
 
 package org.apache.jmeter.extractor;
 
-import static org.junit.Assert.assertThat;
+
+import static org.hamcrest.MatcherAssert.assertThat;
 
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.threads.JMeterContext;
 import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jmeter.threads.JMeterVariables;
 import org.hamcrest.CoreMatchers;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 public class TestBoundaryExtractor {
 
@@ -38,7 +39,7 @@ public class TestBoundaryExtractor {
 
     private JMeterContext jmctx;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         jmctx = JMeterContextService.getContext();
         extractor = new BoundaryExtractor();
@@ -56,6 +57,19 @@ public class TestBoundaryExtractor {
     }
 
     @Test
+    public void testNoBoundariesOneVariable() {
+        vars.put("content", "one");
+        extractor.setMatchNumber(1);
+        extractor.setRefName("varname");
+        extractor.setScopeVariable("content");
+        extractor.setThreadContext(jmctx);
+        extractor.process();
+        assertThat(vars.get("varname"), CoreMatchers.is("one"));
+        assertThat("Indexed variable name should be null", vars.get("varname_1"), CoreMatchers.is(CoreMatchers.nullValue()));
+        assertThat("MatchNumber is incorrect", vars.get("varname_matchNr"), CoreMatchers.is(CoreMatchers.nullValue()));
+    }
+
+    @Test
     public void testNoBoundaries() {
         vars.put("content", "one");
         extractor.setMatchNumber(-1);
@@ -63,9 +77,9 @@ public class TestBoundaryExtractor {
         extractor.setScopeVariable("content");
         extractor.setThreadContext(jmctx);
         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"));
+        assertThat("Non indexed variable name should be null", vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
+        assertThat("First match is incorrect", vars.get("varname_1"), CoreMatchers.is("one"));
+        assertThat("MatchNumber is incorrect", vars.get("varname_matchNr"), CoreMatchers.is("1"));
     }
 
     @Test
@@ -77,9 +91,10 @@ public class TestBoundaryExtractor {
         extractor.setScopeVariable("content");
         extractor.setThreadContext(jmctx);
         extractor.process();
-        assertThat(vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
-        assertThat(vars.get("varname_1"), CoreMatchers.is("ne"));
-        assertThat(vars.get("varname_matchNr"), CoreMatchers.is("1"));
+
+        assertThat("Non indexed variable name should be null", vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
+        assertThat("First match is incorrect", vars.get("varname_1"), CoreMatchers.is("ne"));
+        assertThat("MatchNumber is incorrect", vars.get("varname_matchNr"), CoreMatchers.is("1"));
     }
 
     @Test
@@ -91,9 +106,8 @@ public class TestBoundaryExtractor {
         extractor.setScopeVariable("content");
         extractor.setThreadContext(jmctx);
         extractor.process();
-        assertThat(vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
-        assertThat(vars.get("varname_1"), CoreMatchers.is("on"));
-        assertThat(vars.get("varname_matchNr"), CoreMatchers.is("1"));
+        assertThat("Non indexed variable name should be null", vars.get("varname"), CoreMatchers.is(CoreMatchers.nullValue()));
+        assertThat("First match is incorrect", vars.get("varname_1"), CoreMatchers.is("on"));
+        assertThat("MatchNumber is incorrect", vars.get("varname_matchNr"), CoreMatchers.is("1"));
     }
-
 }
diff --git a/xdocs/usermanual/component_reference.xml b/xdocs/usermanual/component_reference.xml
index 60b27b1..819cb05 100644
--- a/xdocs/usermanual/component_reference.xml
+++ b/xdocs/usermanual/component_reference.xml
@@ -6288,6 +6288,7 @@ generate the template string, and store the result into the given variable name.
     Note that the <code>refName</code> variable is always set to the default value in this case, 
     and the associated group variables are not set.
 </p>
+<note>If both left and right boundary are null, the whole data selected in scope is returned</note>
 </component>
 </section>