Re: svn commit: r1772247 - in /jmeter/trunk: src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java xdocs/chang
Thanks Felix! On Thu, Dec 1, 2016 at 8:39 PM, Felix Schumacher < felix.schumac...@internetallee.de> wrote: > Am 01.12.2016 um 20:05 schrieb Philippe Mouawad: > >> Hi Felix, >> Thanks for patch. >> >> I would create a bugzilla for this one and amend changes (incompatible >> part) as it could introduce regressions in scripts if users relied on >> buggy >> behaviour. >> > Done. > Felix > > I can do it if needed. >> Thx >> Regards >> >> On Thursday, December 1, 2016, wrote: >> >> Author: fschumacher >>> Date: Thu Dec 1 18:39:36 2016 >>> New Revision: 1772247 >>> >>> URL: http://svn.apache.org/viewvc?rev=1772247&view=rev >>> Log: >>> Clear leftover variables before extracting new ones in JSON Extractor. >>> Based on a patch by Qi Chen (qi.chensh at ele.me) >>> >>> This closes #235 on github. >>> >>> Modified: >>> jmeter/trunk/src/components/org/apache/jmeter/extractor/jso >>> n/jsonpath/ >>> JSONPostProcessor.java >>> jmeter/trunk/test/src/org/apache/jmeter/extractor/ >>> TestJSONPostProcessor.java >>> jmeter/trunk/xdocs/changes.xml >>> >>> Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/ >>> json/jsonpath/JSONPostProcessor.java >>> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/ >>> org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java?rev= >>> 1772247&r1=1772246&r2=1772247&view=diff >>> >>> == >>> --- jmeter/trunk/src/components/org/apache/jmeter/extractor/json >>> /jsonpath/JSONPostProcessor.java >>> (original) >>> +++ jmeter/trunk/src/components/org/apache/jmeter/extractor/json >>> /jsonpath/JSONPostProcessor.java >>> Thu Dec 1 18:39:36 2016 >>> @@ -99,6 +99,7 @@ public class JSONPostProcessor extends A >>> int matchNumber = matchNumbers[i]; >>> String currentRefName = refNames[i].trim(); >>> String currentJsonPath = jsonPathExpressions[i].trim(); >>> +clearOldRefVars(vars, currentRefName); >>> try { >>> if (jsonResponse.isEmpty()) { >>> vars.put(currentRefName, defaultValues[i]); >>> @@ -167,7 +168,9 @@ public class JSONPostProcessor extends A >>> vars.put(currentRefName + ALL_SUFFIX, >>> vars.get(currentRefName)); >>> } >>> } >>> -vars.put(currentRefName + REF_MATCH_NR, >>> Integer.toString(extractedValues.size())); >>> +if (matchNumber != 0) { >>> +vars.put(currentRefName + REF_MATCH_NR, >>> Integer.toString(extractedValues.size())); >>> +} >>> } >>> } >>> } catch (Exception e) { >>> @@ -183,6 +186,13 @@ public class JSONPostProcessor extends A >>> } >>> } >>> >>> +private void clearOldRefVars(JMeterVariables vars, String refName) >>> { >>> +vars.remove(refName + REF_MATCH_NR); >>> +for (int i=1; vars.get(refName + "_" + i) != null; i++) { >>> +vars.remove(refName + "_" + i); >>> +} >>> +} >>> + >>> private void placeObjectIntoVars(JMeterVariables vars, String >>> currentRefName, >>> List extractedValues, int matchNr) { >>> vars.put(currentRefName, >>> >>> Modified: jmeter/trunk/test/src/org/apache/jmeter/extractor/ >>> TestJSONPostProcessor.java >>> URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/ >>> apache/jmeter/extractor/TestJSONPostProcessor.java? >>> rev=1772247&r1=1772246&r2=1772247&view=diff >>> >>> == >>> --- jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPo >>> stProcessor.java >>> (original) >>> +++ jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPo >>> stProcessor.java >>> Thu Dec 1 18:39:36 2016 >>> @@ -73,6 +73,70 @@ public class TestJSONPostProcessor { >>> } >>> >>> @Test >>> +public void testProcessRandomElementMultipleMatches() { >>> +JMeterContext context = JMeterContextService.getContext(); >>> +JSONPostProcessor processor = setupProcessor(context, "0", >>> true); >>> +JMeterVariables vars = new JMeterVariables(); >>> +processor.setDefaultValues("NONE"); >>> +processor.setJsonPathExpressions("$[*]"); >>> +processor.setRefNames("varname"); >>> +processor.setScopeVariable("contentvar"); >>> +context.setVariables(vars); >>> +vars.put("contentvar", "[\"one\", \"two\"]"); >>> +processor.process(); >>> +assertThat(vars.get("varname"), CoreMatchers.is(CoreMatchers.a >>> nyOf(CoreMatchers.is("one"), >>> CoreMatchers.is("two"; >>> +assertThat(vars.get("varname_1"), CoreMatchers.is(CoreMatchers. >>> nullValue())); >>> +assertThat(vars.get("varname_2"), CoreMatchers.is(CoreMatchers. >>> nullV
Re: svn commit: r1772247 - in /jmeter/trunk: src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java xdocs/chang
Am 01.12.2016 um 20:05 schrieb Philippe Mouawad: Hi Felix, Thanks for patch. I would create a bugzilla for this one and amend changes (incompatible part) as it could introduce regressions in scripts if users relied on buggy behaviour. Done. Felix I can do it if needed. Thx Regards On Thursday, December 1, 2016, wrote: Author: fschumacher Date: Thu Dec 1 18:39:36 2016 New Revision: 1772247 URL: http://svn.apache.org/viewvc?rev=1772247&view=rev Log: Clear leftover variables before extracting new ones in JSON Extractor. Based on a patch by Qi Chen (qi.chensh at ele.me) This closes #235 on github. Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/ JSONPostProcessor.java jmeter/trunk/test/src/org/apache/jmeter/extractor/ TestJSONPostProcessor.java jmeter/trunk/xdocs/changes.xml Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/ json/jsonpath/JSONPostProcessor.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/ org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java?rev= 1772247&r1=1772246&r2=1772247&view=diff == --- jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java (original) +++ jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java Thu Dec 1 18:39:36 2016 @@ -99,6 +99,7 @@ public class JSONPostProcessor extends A int matchNumber = matchNumbers[i]; String currentRefName = refNames[i].trim(); String currentJsonPath = jsonPathExpressions[i].trim(); +clearOldRefVars(vars, currentRefName); try { if (jsonResponse.isEmpty()) { vars.put(currentRefName, defaultValues[i]); @@ -167,7 +168,9 @@ public class JSONPostProcessor extends A vars.put(currentRefName + ALL_SUFFIX, vars.get(currentRefName)); } } -vars.put(currentRefName + REF_MATCH_NR, Integer.toString(extractedValues.size())); +if (matchNumber != 0) { +vars.put(currentRefName + REF_MATCH_NR, Integer.toString(extractedValues.size())); +} } } } catch (Exception e) { @@ -183,6 +186,13 @@ public class JSONPostProcessor extends A } } +private void clearOldRefVars(JMeterVariables vars, String refName) { +vars.remove(refName + REF_MATCH_NR); +for (int i=1; vars.get(refName + "_" + i) != null; i++) { +vars.remove(refName + "_" + i); +} +} + private void placeObjectIntoVars(JMeterVariables vars, String currentRefName, List extractedValues, int matchNr) { vars.put(currentRefName, Modified: jmeter/trunk/test/src/org/apache/jmeter/extractor/ TestJSONPostProcessor.java URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/ apache/jmeter/extractor/TestJSONPostProcessor.java? rev=1772247&r1=1772246&r2=1772247&view=diff == --- jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java (original) +++ jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java Thu Dec 1 18:39:36 2016 @@ -73,6 +73,70 @@ public class TestJSONPostProcessor { } @Test +public void testProcessRandomElementMultipleMatches() { +JMeterContext context = JMeterContextService.getContext(); +JSONPostProcessor processor = setupProcessor(context, "0", true); +JMeterVariables vars = new JMeterVariables(); +processor.setDefaultValues("NONE"); +processor.setJsonPathExpressions("$[*]"); +processor.setRefNames("varname"); +processor.setScopeVariable("contentvar"); +context.setVariables(vars); +vars.put("contentvar", "[\"one\", \"two\"]"); +processor.process(); +assertThat(vars.get("varname"), CoreMatchers.is(CoreMatchers.anyOf(CoreMatchers.is("one"), CoreMatchers.is("two"; +assertThat(vars.get("varname_1"), CoreMatchers.is(CoreMatchers. nullValue())); +assertThat(vars.get("varname_2"), CoreMatchers.is(CoreMatchers. nullValue())); +assertThat(vars.get("varname_matchNr"), CoreMatchers.is(CoreMatchers.nullValue())); +} + +@Test +public void testPR235CaseEmptyResponse() { +JMeterContext context = JMeterContextService.getContext(); +JSONPostProcessor processor = setupProcessor(context, "-1", true); +JMeterVariables vars = new JMeterVariables(); +processor.setDefaultValues("NONE"); +processor.setJsonPathExpressions("$[*]"); +processor.setRefNames("varname"); +processor.setScopeVariable("contentvar"); +contex
Re: svn commit: r1772247 - in /jmeter/trunk: src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java xdocs/chang
Hi Felix, Thanks for patch. I would create a bugzilla for this one and amend changes (incompatible part) as it could introduce regressions in scripts if users relied on buggy behaviour. I can do it if needed. Thx Regards On Thursday, December 1, 2016, wrote: > Author: fschumacher > Date: Thu Dec 1 18:39:36 2016 > New Revision: 1772247 > > URL: http://svn.apache.org/viewvc?rev=1772247&view=rev > Log: > Clear leftover variables before extracting new ones in JSON Extractor. > Based on a patch by Qi Chen (qi.chensh at ele.me) > > This closes #235 on github. > > Modified: > jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/ > JSONPostProcessor.java > jmeter/trunk/test/src/org/apache/jmeter/extractor/ > TestJSONPostProcessor.java > jmeter/trunk/xdocs/changes.xml > > Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/ > json/jsonpath/JSONPostProcessor.java > URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/ > org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java?rev= > 1772247&r1=1772246&r2=1772247&view=diff > > == > --- > jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java > (original) > +++ > jmeter/trunk/src/components/org/apache/jmeter/extractor/json/jsonpath/JSONPostProcessor.java > Thu Dec 1 18:39:36 2016 > @@ -99,6 +99,7 @@ public class JSONPostProcessor extends A > int matchNumber = matchNumbers[i]; > String currentRefName = refNames[i].trim(); > String currentJsonPath = jsonPathExpressions[i].trim(); > +clearOldRefVars(vars, currentRefName); > try { > if (jsonResponse.isEmpty()) { > vars.put(currentRefName, defaultValues[i]); > @@ -167,7 +168,9 @@ public class JSONPostProcessor extends A > vars.put(currentRefName + ALL_SUFFIX, > vars.get(currentRefName)); > } > } > -vars.put(currentRefName + REF_MATCH_NR, > Integer.toString(extractedValues.size())); > +if (matchNumber != 0) { > +vars.put(currentRefName + REF_MATCH_NR, > Integer.toString(extractedValues.size())); > +} > } > } > } catch (Exception e) { > @@ -183,6 +186,13 @@ public class JSONPostProcessor extends A > } > } > > +private void clearOldRefVars(JMeterVariables vars, String refName) { > +vars.remove(refName + REF_MATCH_NR); > +for (int i=1; vars.get(refName + "_" + i) != null; i++) { > +vars.remove(refName + "_" + i); > +} > +} > + > private void placeObjectIntoVars(JMeterVariables vars, String > currentRefName, > List extractedValues, int matchNr) { > vars.put(currentRefName, > > Modified: jmeter/trunk/test/src/org/apache/jmeter/extractor/ > TestJSONPostProcessor.java > URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/ > apache/jmeter/extractor/TestJSONPostProcessor.java? > rev=1772247&r1=1772246&r2=1772247&view=diff > > == > --- > jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java > (original) > +++ > jmeter/trunk/test/src/org/apache/jmeter/extractor/TestJSONPostProcessor.java > Thu Dec 1 18:39:36 2016 > @@ -73,6 +73,70 @@ public class TestJSONPostProcessor { > } > > @Test > +public void testProcessRandomElementMultipleMatches() { > +JMeterContext context = JMeterContextService.getContext(); > +JSONPostProcessor processor = setupProcessor(context, "0", true); > +JMeterVariables vars = new JMeterVariables(); > +processor.setDefaultValues("NONE"); > +processor.setJsonPathExpressions("$[*]"); > +processor.setRefNames("varname"); > +processor.setScopeVariable("contentvar"); > +context.setVariables(vars); > +vars.put("contentvar", "[\"one\", \"two\"]"); > +processor.process(); > +assertThat(vars.get("varname"), > CoreMatchers.is(CoreMatchers.anyOf(CoreMatchers.is("one"), > CoreMatchers.is("two"; > +assertThat(vars.get("varname_1"), CoreMatchers.is(CoreMatchers. > nullValue())); > +assertThat(vars.get("varname_2"), CoreMatchers.is(CoreMatchers. > nullValue())); > +assertThat(vars.get("varname_matchNr"), > CoreMatchers.is(CoreMatchers.nullValue())); > +} > + > +@Test > +public void testPR235CaseEmptyResponse() { > +JMeterContext context = JMeterContextService.getContext(); > +JSONPostProcessor processor = setupProcessor(context, "-1", true); > +JMeterVariables vars = new JMeterVariables(); > +processor.setDefaultValues("NONE"); > +processor.setJ
[GitHub] jmeter issue #235: reset the matchNr and all the values, otherwise the 'ForE...
Github user FSchumacher commented on the issue: https://github.com/apache/jmeter/pull/235 Thanks for your contribution. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] jmeter pull request #235: reset the matchNr and all the values, otherwise th...
Github user asfgit closed the pull request at: https://github.com/apache/jmeter/pull/235 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
RE: How should no-op setter methods be filed in Bugzilla?
> -Original Message- > From: Felix Schumacher [mailto:felix.schumac...@internetallee.de] > Sent: Monday, November 28, 2016 2:51 PM > To: dev@jmeter.apache.org > Subject: RE: How should no-op setter methods be filed in Bugzilla? > > The class you mentioned uses an instance variable instead of using > this.setProperty(...), so I thought that this might be your problem and > wanted to ask, of the other examples you found, have the same property > (that is, not using setProperty). You know, I hadn't thought of that! That could be a promising lead; I'll take a closer look and see if I can confirm/deny. If that _is_ the case, what do you suppose would be the correct approach to fixing the problem? IMO, the "obvious" solution is to prefer setProperty() in setter methods. But that's both ugly to look at and not enforceable in code, so it only exists by convention (i.e. still really easy to mess it up). I believe it would be more robust and sensible to consider this a bug in SaveService failing to lower user-facing properties so they can be included in the output. >> I've tried. XStream is kind of obtuse, and I'm still trying to figure >> out the point where the data structure is lowered to a HashTree that >> SaveService can work with. If I knew that, I might be able to _fix_ it. > > I would love to hear more about this, when you have something to report > here. I wonder if someone else here can point me in the right direction? Sebb? Cheers, Wyatt Confidentiality Notice: This electronic message transmission, including any attachment(s), may contain confidential, proprietary, or privileged information from Chemical Abstracts Service ("CAS"), a division of the American Chemical Society ("ACS"). If you have received this transmission in error, be advised that any disclosure, copying, distribution, or use of the contents of this information is strictly prohibited. Please destroy all copies of the message and contact the sender immediately by either replying to this message or calling 614-447-3600.