You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Felix Schumacher <fe...@internetallee.de> on 2017/05/03 13:03:04 UTC

Re: svn commit: r1793271 - /jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java

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/TestValueReplacer.java
> 
> Modified:
> jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
> URL:
> http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java?rev=1793271&r1=1793270&r2=1793271&view=diff
> ==============================================================================
> ---
> jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
> (original)
> +++
> jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
> Sun Apr 30 20:34:17 2017
> @@ -107,6 +107,24 @@ public class TestValueReplacer extends J
>              String replacedDomain = 
> element.getPropertyAsString("domain");
>              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?

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.

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 {

Re: svn commit: r1793271 - /jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java

Posted by Felix Schumacher <fe...@internetallee.de>.
Ping.

Felix

Am 3. Mai 2017 15:03:04 MESZ schrieb Felix Schumacher <fe...@internetallee.de>:
>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/TestValueReplacer.java
>> 
>> Modified:
>>
>jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
>> URL:
>>
>http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java?rev=1793271&r1=1793270&r2=1793271&view=diff
>>
>==============================================================================
>> ---
>>
>jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
>> (original)
>> +++
>>
>jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java
>> Sun Apr 30 20:34:17 2017
>> @@ -107,6 +107,24 @@ public class TestValueReplacer extends J
>>              String replacedDomain = 
>> element.getPropertyAsString("domain");
>>              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?
>
>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.
>
>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 {

Re: svn commit: r1793271 - /jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java

Posted by Philippe Mouawad <ph...@gmail.com>.
Thanks will do.
I'd be more than happy if you could also answer other mails I sent related
to features, future of JMeter, percentiles/median ...

Regards

On Sun, May 28, 2017 at 4:02 PM, sebb <se...@gmail.com> wrote:

> On 23 May 2017 at 11:03, Philippe Mouawad <ph...@gmail.com>
> wrote:
> > 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.
>
> In which case, please add some comments as to what the code is trying to
> test.
> Someone else can then give it a new name if they wish.
>
> Without either a hint from the name or some comments it's going to be
> very difficult for future maintainers to debug if the test ever fails.
>
> >>
> >> 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.
>



-- 
Cordialement.
Philippe Mouawad.

Re: svn commit: r1793271 - /jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java

Posted by sebb <se...@gmail.com>.
On 23 May 2017 at 11:03, Philippe Mouawad <ph...@gmail.com> wrote:
> 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.

In which case, please add some comments as to what the code is trying to test.
Someone else can then give it a new name if they wish.

Without either a hint from the name or some comments it's going to be
very difficult for future maintainers to debug if the test ever fails.

>>
>> 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.

Re: svn commit: r1793271 - /jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java

Posted by Felix Schumacher <fe...@internetallee.de>.
Am 23.05.2017 um 12:03 schrieb Philippe Mouawad:
> 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.
Ok, so the two matches were misleading me. I have rewritten the test 
case to four distinct test cases and removed the firstMatch, which I 
think is not necessary for this one.


>
>> 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.
I tried to give meaningful names to the new tests. I hope you like them :)

Sorry for my late reply, but I didn't expect any more text after your 
first "Regards".

Felix

>
>> 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 {
>>>
>


Re: svn commit: r1793271 - /jmeter/trunk/test/src/org/apache/jmeter/engine/util/TestValueReplacer.java

Posted by Philippe Mouawad <ph...@gmail.com>.
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.