Description Port numbers of HTTP requests cannot be changed through search and replace. Steps to reproduce 1. Create a HTTP Request sampler with a port 'XXX' 2. Click [ctrl+f] 3. Enter the port 'XXX' into the search field. 4. Enter something into the 'Replace by' field.
Created attachment 36358 [details] Jar to be replaced in JMETER_DIR\lib\ext\ Replace the jar to get the search and replace functionality for entire Jmeter test plan.
Created attachment 36359 [details] Source code to fix search and replace functionality in Jmeter 5.0 Source code location to replace: /jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
Hello, Issue has been fixed by adding a code block in Jmeter Http sampler base. Kindly verify and confirm. Thanks, Mohamed Ibrahim
A bug entry should be closed, when the bug report is either invalid, or solved in trunk. As this is a valid report (thank you for opening it) and it hasn't been fixed in trunk, it should be in open status.
Created attachment 36360 [details] Replace port and protocol in HTTP Samplers This is basically the diff from the originally attached source. It has been refactored to eliminate duplicate code. That should make it easy to add more parameters to be replaced, like the proxy parameters.
(In reply to Felix Schumacher from comment #5) > Created attachment 36360 [details] > Replace port and protocol in HTTP Samplers > > This is basically the diff from the originally attached source. It has been > refactored to eliminate duplicate code. That should make it easy to add more > parameters to be replaced, like the proxy parameters. Hello, Thanks for patch. Look good to me except that if I understand correctly, it would not be possible to replace port by ${portNumber} due to this: (s) -> setPort(Integer.parseInt(s) Regards
Hello all, This is my first try in contribution to open source. I just followed the steps given in the following apache page https://jmeter.apache.org/building.html I did exactly whatever has been given in the instructions. But, I don't know how it was not updated in the trunk. You can still check my forked repo in github. https://github.com/rollno748/jmeter/blob/63025/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerProxy.java I was trying my best to do it to push the code. Please let me know where i went wrong and Is there any proper documentation available code committing?
(In reply to Philippe Mouawad from comment #6) > (In reply to Felix Schumacher from comment #5) > > Created attachment 36360 [details] > > Replace port and protocol in HTTP Samplers > > > > This is basically the diff from the originally attached source. It has been > > refactored to eliminate duplicate code. That should make it easy to add more > > parameters to be replaced, like the proxy parameters. > > Hello, > Thanks for patch. > Look good to me except that if I understand correctly, it would not be > possible to replace port by ${portNumber} due to this: > > (s) -> setPort(Integer.parseInt(s) That has to be done, as setPort accepts int, only. The expression is probably set on the ui element and not on the sampler. > > Regards
(In reply to Mohamed Ibrahim from comment #7) > Hello all, > > This is my first try in contribution to open source. > I just followed the steps given in the following apache page > https://jmeter.apache.org/building.html And you did great. > > > > I did exactly whatever has been given in the instructions. But, I don't know > how it was not updated in the trunk. JMeter's trunk can only be updated by Committers. See https://www.apache.org/foundation/getinvolved.html for more on this. I suspect, you followed the "Create a PR using GIT" instruction on the building page. There is one last step there, that you missed. It is the creation of the pull request. That way we would have been notified of your changes. For more information and or further discussion about contributing, I suggest that you subscribe to the users (or developers) mailing list and send your questions/suggestions there. > > You can still check my forked repo in github. > > https://github.com/rollno748/jmeter/blob/63025/src/protocol/http/org/apache/ > jmeter/protocol/http/sampler/HTTPSamplerProxy.java > > > I was trying my best to do it to push the code. And thanks again for trying. > > Please let me know where i went wrong and Is there any proper documentation > available code committing?
(In reply to Felix Schumacher from comment #8) > (In reply to Philippe Mouawad from comment #6) > > (In reply to Felix Schumacher from comment #5) > > > Created attachment 36360 [details] > > > Replace port and protocol in HTTP Samplers > > > > > > This is basically the diff from the originally attached source. It has been > > > refactored to eliminate duplicate code. That should make it easy to add more > > > parameters to be replaced, like the proxy parameters. > > > > Hello, > > Thanks for patch. > > Look good to me except that if I understand correctly, it would not be > > possible to replace port by ${portNumber} due to this: > > > > (s) -> setPort(Integer.parseInt(s) > > That has to be done, as setPort accepts int, only. The expression is > probably set on the ui element and not on the sampler. > > > > > > Regards Hi Felix, I think we can safely introduce this setPort(String value) method. When we read it, it's read as StringProperty. I don't want to commit your work as you should be the committer (I don't want to have credit for your work :-) ), so if you can commit this code, I can add it later or you can also do it if you want. Thanks
Thanks for the report and initial code example. This will be included in version 5.1. It would be really nice, if you could test the next nightly, if this fix does what you want. (You can close this enhancement, if it works for you) In the end I decided to change directly the properties that contain the string representation for port and protocol instead of the derived values, that getPort and getProtocol return. Date: Sat Jan 5 12:06:49 2019 New Revision: 1850475 URL: http://svn.apache.org/viewvc?rev=1850475&view=rev Log: Extract duplicate code into private method Refactoring to make bug 63025 easier to fix. Bugzilla Id: 63025 Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java Date: Sat Jan 5 12:19:26 2019 New Revision: 1850478 URL: http://svn.apache.org/viewvc?rev=1850478&view=rev Log: Enhance Search & Replace functionality for HTTP Request to include port and protocol field. Bugzilla Id: 63025 Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java jmeter/trunk/xdocs/changes.xml
(In reply to Philippe Mouawad from comment #10) > (In reply to Felix Schumacher from comment #8) > > (In reply to Philippe Mouawad from comment #6) > > > (In reply to Felix Schumacher from comment #5) > > > > Created attachment 36360 [details] > > > > Replace port and protocol in HTTP Samplers > > > > > > > > This is basically the diff from the originally attached source. It has been > > > > refactored to eliminate duplicate code. That should make it easy to add more > > > > parameters to be replaced, like the proxy parameters. > > > > > > Hello, > > > Thanks for patch. > > > Look good to me except that if I understand correctly, it would not be > > > possible to replace port by ${portNumber} due to this: > > > > > > (s) -> setPort(Integer.parseInt(s) > > > > That has to be done, as setPort accepts int, only. The expression is > > probably set on the ui element and not on the sampler. > > > > > > > > > > Regards > > Hi Felix, > I think we can safely introduce this setPort(String value) method. > When we read it, it's read as StringProperty. I opted to change the property directly. That makes it really easy to add more properties if we want to change them as well. I wonder if we should use that path for the already implemented getDomain and getPath as getPath changes the property value by encoding spaces. > > I don't want to commit your work as you should be the committer (I don't > want to have credit for your work :-) ), so if you can commit this code, I > can add it later or you can also do it if you want. No problem, I would not have been angry with you. > > Thanks
Date: Sat Jan 5 12:45:32 2019 New Revision: 1850484 URL: http://svn.apache.org/viewvc?rev=1850484&view=rev Log: Mention contributor of initial code for fix of bug 63025 Bugzilla Id: 63025 Modified: jmeter/trunk/xdocs/changes.xml
Date: Sat Jan 5 21:51:33 2019 New Revision: 1850515 URL: http://svn.apache.org/viewvc?rev=1850515&view=rev Log: Further code deduplication for Replaceable Part of Bugzilla Id: 63025 Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HeaderManager.java jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java jmeter/trunk/test/src/org/apache/jorphan/util/TestJorphanUtils.java
Date: Sat Jan 5 21:56:31 2019 New Revision: 1850516 URL: http://svn.apache.org/viewvc?rev=1850516&view=rev Log: Correct number of replaced values Bugzilla Id: 63025 Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/control/HeaderManager.java
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4956