Summary: | New __changeCase function | ||
---|---|---|---|
Product: | JMeter - Now in Github | Reporter: | Philippe Mouawad <p.mouawad> |
Component: | Main | Assignee: | JMeter issues mailing list <issues> |
Status: | RESOLVED FIXED | ||
Severity: | enhancement | CC: | orimarko, p.mouawad |
Priority: | P2 | ||
Version: | 3.3 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Attachments: |
Patch with new change case function
Patch with update changeCase add support of non English letters Update patch remove camel case Remove camel case from messages |
Description
Philippe Mouawad
2017-11-14 18:28:41 UTC
I suggest adding camel case support (as myVarName), new mode: CAMEL_CASE What is the use case for these? I'd prefer separate functions i.e.: __toUpper(string, outputVarName) __toLower(string, outputVarName) I think we could have __capitalise(string, outputVarName) but it is a bit ambiguous, does it mean just the first letter, or for each sentence or "fully" i.e. each letter after whitespace? Camel case doesn't seem a common use case to warrant adding, I could be wrong, what did you have in mind? It seems to me ambiguous and hard to implement, what sort of camel case would it apply to "thiscouldbecamelcased" as I'd expect "thisCouldBeCamelCased", but this woudn't be possible to implement well, especially across languages. Actually, I prefer: __toUpper(string) __toLower(string) which just return the result, rather than having another variable. Similar to __urlencode. (In reply to Graham Russell from comment #3) > Actually, I prefer: > > __toUpper(string) > __toLower(string) > > which just return the result, rather than having another variable. Similar > to __urlencode. The aim was to avoid having too many functions. I feel having a MODE (enum in Java) would be interesting as it would allow adding modes without having to introduce new functions. It is true that CAPITALIZE might be luxurious, but as it's available with StringUtils and I had the need 2 or 3 times in my work I thought it might be interesting. We can also add CamelCase This is slightly off topic (or rather overarching), but to prevent the aversion to introducing more but well named functions we should better design the function names and the function helper. Perhaps something like __StringUtils.toUpper() and the function helper GUI can be organised to group based on the grouping? I will start an email discussion if this seems useful? About camel case, we should distinguish between upper and lower camel case, Someone can expect camelCaseMode or CamelCaseMode I suggest 2 modes: CAMEL_CASE and CAMEL_CASE_FIRST_LOWER I suggest it will get a string as "abc_def-Ghi jkl" and return AbcDefGhiJkl or abcDefGhiJkl My suggestion: - __changeCase(string, MODE, exported_var) Where modes would be: - UPPER (default value) - LOWER - CAPITALIZE - CAMEL_CASE - CAMEL_CASE_FIRST_LOWER Only first variable is mandatory ok for me (In reply to orimarko from comment #7) > My suggestion: > > - __changeCase(string, MODE, exported_var) > > Where modes would be: > - UPPER (default value) > - LOWER > - CAPITALIZE > - CAMEL_CASE > - CAMEL_CASE_FIRST_LOWER > > Only first variable is mandatory Created attachment 35538 [details]
Patch with new change case function
Patch with new change case function and tests and documentation
Fixed also duplicate sect-num in functions
Author: pmouawad Date: Mon Nov 20 19:50:51 2017 New Revision: 1815838 URL: http://svn.apache.org/viewvc?rev=1815838&view=rev Log: Bug 61759 - New __changeCase function Contributed by Orimarko Bugzilla Id: 61759 Added: jmeter/trunk/src/functions/org/apache/jmeter/functions/ChangeCase.java (with props) jmeter/trunk/test/src/org/apache/jmeter/functions/TestChangeCase.java (with props) Modified: jmeter/trunk/xdocs/changes.xml jmeter/trunk/xdocs/usermanual/functions.xml Author: pmouawad Date: Mon Nov 20 19:59:48 2017 New Revision: 1815839 URL: http://svn.apache.org/viewvc?rev=1815839&view=rev Log: Bug 61759 - New __changeCase function Add i18n Bugzilla Id: 61759 Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Author: pmouawad Date: Mon Nov 20 20:34:10 2017 New Revision: 1815851 URL: http://svn.apache.org/viewvc?rev=1815851&view=rev Log: Bug 61759 - New __changeCase function Handle first char Uppercase error Bugzilla Id: 61759 Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/ChangeCase.java jmeter/trunk/test/src/org/apache/jmeter/functions/TestChangeCase.java Author: pmouawad Date: Mon Nov 20 20:55:50 2017 New Revision: 1815855 URL: http://svn.apache.org/viewvc?rev=1815855&view=rev Log: Bug 61759 - New __changeCase function Fix checkstyle error Bugzilla Id: 61759 Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/ChangeCase.java Author: pmouawad Date: Wed Nov 22 07:27:11 2017 New Revision: 1816006 URL: http://svn.apache.org/viewvc?rev=1816006&view=rev Log: Bug 61759 __changeCase</code> function to change different cases of a string Take into account some remarks from Felix: - Change enum names - Make CamelCase work as described in wikipedia - rename cz Bugzilla Id: 61759 Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/ChangeCase.java jmeter/trunk/test/src/org/apache/jmeter/functions/TestChangeCase.java jmeter/trunk/xdocs/usermanual/functions.xml About regex support of non English letter as umlauts, I suggest to use include expression [\s\-_]+ Which split words by any group of Whitespace character (\s) hyphen (-) and Undercore (_) Created attachment 35545 [details]
Patch with update changeCase add support of non English letters
I thought camel case would be a nice to have feature, But it's not using Apache code as the other cases and I'm not sure it's needed and it raises questions/issues, I'm voting to currently remove camel case option from changeCase function I agree with removal. I can't see a use case for it, at least not one worth keeping the code in core. If someone really needs it they can write their own with the particular requirements they have. Created attachment 35567 [details]
Update patch remove camel case
Author: pmouawad Date: Sat Dec 9 14:31:49 2017 New Revision: 1817615 URL: http://svn.apache.org/viewvc?rev=1817615&view=rev Log: Bug 61759 - New __changeCase function Remove camel case as per Ori Marko contribution More edge cases for changeCase function and slight behaviour changes contributed by Felix Schumacher This closes #342 Bugzilla Id: 61759 Added: jmeter/trunk/test/src/org/apache/jmeter/functions/ChangeCaseSpec.groovy Modified: jmeter/trunk/src/functions/org/apache/jmeter/functions/ChangeCase.java jmeter/trunk/test/src/org/apache/jmeter/functions/TestChangeCase.java jmeter/trunk/xdocs/usermanual/functions.xml Created attachment 35599 [details]
Remove camel case from messages
Remove camel case from messages
Add patch to remove camel case from messages Author: pmouawad Date: Sat Dec 23 14:31:52 2017 New Revision: 1819152 URL: http://svn.apache.org/viewvc?rev=1819152&view=rev Log: Bug 61759 - New __changeCase function Remove useless message labels as per orimarko patch Bugzilla Id: 61759 Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4587 |