jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philippe Mouawad <philippe.moua...@gmail.com>
Subject Re: svn commit: r1793271 - /jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
Date Tue, 23 May 2017 10:03:19 GMT
Hi Felix,
Sorry for no reply , it was out of my radar.

Regards

On Wed, May 3, 2017 at 3:03 PM, Felix Schumacher <
felix.schumacher@internetallee.de> wrote:

> Am 30.04.2017 22:34, schrieb pmouawad@apache.org:
>
>> Author: pmouawad
>> Date: Sun Apr 30 20:34:17 2017
>> New Revision: 1793271
>>
>> URL: http://svn.apache.org/viewvc?rev=1793271&view=rev
>> Log:
>> Add test case to show partial replacement does not work
>>
>> Modified:
>>     jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValu
>> eReplacer.java
>>
>> Modified:
>> jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValu
>> eReplacer.java
>> URL:
>> http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apach
>> e/jmeter/engine/util/TestValueReplacer.java?rev=1793271&r1=
>> 1793270&r2=1793271&view=diff
>> ============================================================
>> ==================
>> ---
>> jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValu
>> eReplacer.java
>> (original)
>> +++
>> jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValu
>> eReplacer.java
>> Sun Apr 30 20:34:17 2017
>> @@ -107,6 +107,24 @@ public class TestValueReplacer extends J
>>              String replacedDomain = element.getPropertyAsString("d
>> omain");
>>              assertEquals("${${shortMatch}", replacedDomain);
>>          }
>> +
>> +        @Test
>> +        public void test2Matches() throws Exception {
>> +            TestPlan plan = new TestPlan();
>> +            plan.addParameter("firstMatch", "toto");
>> +            plan.addParameter("secondMatch", "005");
>> +            ValueReplacer replacer = new ValueReplacer(plan);
>> +            TestElement element = new TestPlan();
>> +            element.setProperty(new StringProperty("mail",
>> "toto%40005"));
>>
>
> If you want to replace 005 "in" a word (40005), then you have to surround
> the regex with parentheses. The '%' is a word boundary, '0' is not.
>
> So instead of "005" you have to write "(005)". The behaviour is described
> in http://jmeter.apache.org/usermanual/component_reference.
> html#HTTP(S)_Test_Script_Recorder
> and further down on that page under "User Defined Variable replacement".
>
> But maybe you wanted to document that behaviour here?
>
Yes. I wanted to document that due to encoding, replacement of 005 would
not work.

>
> A few notes on the test itself. I like tests, that test one thing in one
> method - this tests two things.
> It might help, if the test name hints at the problem by using a name, that
> is a bit more descriptive.
>

I agree, but I don't know how to name it.

>
> Regards,
>  Felix
>
>
> +            replacer.reverseReplace(element, true);
>> +            String replacedDomain = element.getPropertyAsString("mail");
>> +            assertEquals("${firstMatch}%40005", replacedDomain);
>> +
>> +            element.setProperty(new StringProperty("mail", "toto@005"));
>> +            replacer.reverseReplace(element, true);
>> +            replacedDomain = element.getPropertyAsString("mail");
>> +            assertEquals("${firstMatch}@${secondMatch}",
>> replacedDomain);
>> +        }
>>
>>          @Test
>>          public void testReplace() throws Exception {
>>
>


-- 
Cordialement.
Philippe Mouawad.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message