Summary: | Only default parameters of Java Request Samplers are stored | ||
---|---|---|---|
Product: | JMeter - Now in Github | Reporter: | chris.p |
Component: | Main | Assignee: | JMeter issues mailing list <issues> |
Status: | NEEDINFO --- | ||
Severity: | enhancement | ||
Priority: | P2 | ||
Version: | 3.1 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All |
Description
chris.p
2007-07-12 04:04:47 UTC
According to the documentation, the Add/Delete buttons do not serve any purpose. So this is a feature request and not a bug report. It would be great, if this feature could be implemented soon. If this is not possible, please tell me. Then I will have to find another solution for my problem. Thank You! Unlikely to be fixed in near future, so if you want a quick solution, I suggest you add some more optional parameters to your client. I have a same problem. But I can to fix it. To fix this bug you may apply this patch: Add this code to the JavaConfigGui.java (version 2.9): public void actionPerformed(ActionEvent evt) { ... if (currArgs.getArgumentCount() != 0) { // Already configured - skip getting defaults argsPanel.configure(currArgs); return; } ... Full method code: @Override public void actionPerformed(ActionEvent evt) { if (evt.getSource() == classnameCombo) { String className = ((String) classnameCombo.getSelectedItem()).trim(); try { JavaSamplerClient client = (JavaSamplerClient) Class.forName(className, true, Thread.currentThread().getContextClassLoader()).newInstance(); Arguments currArgs = new Arguments(); argsPanel.modifyTestElement(currArgs); if (currArgs.getArgumentCount() != 0) { // Already configured - skip getting defaults argsPanel.configure(currArgs); return; } Map<String, String> currArgsMap = currArgs.getArgumentsAsMap(); Arguments newArgs = new Arguments(); Arguments testParams = null; try { testParams = client.getDefaultParameters(); } catch (AbstractMethodError e) { log.warn("JavaSamplerClient doesn't implement " + "getDefaultParameters. Default parameters won't " + "be shown. Please update your client class: " + className); } if (testParams != null) { PropertyIterator i = testParams.getArguments().iterator(); while (i.hasNext()) { Argument arg = (Argument) i.next().getObjectValue(); String name = arg.getName(); String value = arg.getValue(); // If a user has set parameters in one test, and then // selects a different test which supports the same // parameters, those parameters should have the same // values that they did in the original test. if (currArgsMap.containsKey(name)) { String newVal = currArgsMap.get(name); if (newVal != null && newVal.length() > 0) { value = newVal; } } newArgs.addArgument(name, value); } } argsPanel.configure(newArgs); } catch (Exception e) { log.error("Error getting argument list for " + className, e); } } } Any chance the below patch could get applied to trunk? Unfortunately, this fix is not correct with the logic of the Java Sampler. With this patch, if I add a Java Sampler with JavaTest, I have some parameters (like ResultData, SamplerData, etc.), then (always in the same sampler and without any modification), when I change the classname to SleepTest, I keep the JavaTest parameters and I don't have the SleepTest params (SleepTime and SleepMask)! It's normal to reset the params when you change the classname (the if statement : "if (evt.getSource() == classnameCombo) { }"). If your issue is to allow to save the additional params added by the Add button, the patch would be more bigger. (In reply to Milamber from comment #5) > > Unfortunately, this fix is not correct with the logic of the Java Sampler. > > With this patch, if I add a Java Sampler with JavaTest, I have some > parameters (like ResultData, SamplerData, etc.), then (always in the same > sampler and without any modification), when I change the classname to > SleepTest, I keep the JavaTest parameters and I don't have the SleepTest > params (SleepTime and SleepMask)! But that is easy to work-around, just remove all the values and then select the class you want and the defaults get added in. That seemed to work fine for me and didn't add any more sigficiant complexity in the process, just needed to know if I didn't want the current values for that sampler. > > It's normal to reset the params when you change the classname (the if > statement : "if (evt.getSource() == classnameCombo) { }"). > > If your issue is to allow to save the additional params added by the Add > button, the patch would be more bigger. Agreed, but that would require quite a change to the logic as it would require knowing if you had just changed the Java sampler or not. However this patch does resolve the issue without needing a complete re-write of the sampler. This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/1975 |