Bug 40077 - Creating new Elements copies values from Existing elements
Summary: Creating new Elements copies values from Existing elements
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: unspecified
Hardware: Other All
: P2 regression (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Depends on:
Reported: 2006-07-20 10:16 UTC by Geoff Willingham
Modified: 2007-06-10 10:44 UTC (History)
0 users

Suggested patch (22.53 KB, patch)
2007-05-03 06:44 UTC, Alf Hogemark
Details | Diff
Updated suggested patch (42.45 KB, patch)
2007-05-04 02:13 UTC, Alf Hogemark
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoff Willingham 2006-07-20 10:16:24 UTC
This issue affects an unknown number of Test Elements.  The Regular Expression
Extractor gui will be used as an example for this report.

The GUI panel implements the createTestElement() function by creating a new
instance of the RegexExtractor, and then passing it to the modifyTestElement()
function to initialise its parameters.

The problem with this approach is that if an existing RegexExtractor is selected
in the tree view, any newly created RegexExtractors that are created will be
pre-populated with the details of the selected RegexExtractor.  

This should be changed to ensure that newly created elements are always
initialised to known default values (probably empty strings in most cases).  

Existing behaviour (effectivly cloning the existing element) can be achieved via
Comment 1 Alf Hogemark 2007-05-03 06:44:42 UTC
Created attachment 20119 [details]
Suggested patch

The problem is caused by missing implementation of "clear" method in the GUI

This patch adds correct implementation of "clear" method for preprocessors,
postprocessors, assertions and some of the samplers.

What remains are most of the samplers, but those GUI classes are a bit complex.

It also remains to implement clear in some of the config elements.

Note that the logic controllers have been updated in patch in bug 42325.
Comment 2 Alf Hogemark 2007-05-04 02:13:45 UTC
Created attachment 20129 [details]
Updated suggested patch

This updated patch also implements clear in config and samplers.

What still remains are the Java sampler and config, and the mailer and jms
samplers and configs. I have problems understanding and testing those, so I
will not fix those at the moment.
Comment 3 Sebb 2007-05-04 02:30:30 UTC

Patch 20129 has been applied to SVN in r535138.
Comment 4 Sebb 2007-06-03 06:18:42 UTC
The fix seems to have caused some other problems.

For example, select a Sampler with non-default data.
Menu/Run/Clear now resets the sampler back to the default state.

The purpose of the Clear/Clear All functions is to clear the sampler data, not 
the test elements.

It might be useful to implement a test element reset function, but that should 
be a separate command under the Edit Menu.

The problem needs to be fixed where the new elements are created.
I'll have a further look at this.
Comment 5 Sebb 2007-06-03 07:03:10 UTC
Seems to that the clear() method() is being used for two purposes:
- clearing the GUI fields (JMeterGUIComponent interface)
- clearing data from Listeners (the Clearable interface)

One of these probably needs to be renamed.
Comment 6 Sebb 2007-06-04 08:36:47 UTC
I now think they should both be renamed:
- ensures that they are all replaced
- reduces confusion in future
Comment 7 Sebb 2007-06-04 16:21:03 UTC
I've done quite a bit of work to fix this (not yet committed).

After I replaced the clear() methods with clearGui() and clearData(), I then 
found that there is yet another clear() method in the TestElement interface!

This is definitely not clearGui(), nor does it appear to be clearData() as it 
is not used to clear runtime data.

The good news is that the Gui elements now behave better.
Comment 8 Sebb 2007-06-05 16:53:24 UTC
The refactoring was added to SVN in 544682.

There are one or two Gui elements that have not yet been fixed.
Comment 9 Alf Hogemark 2007-06-06 12:28:15 UTC
(In reply to comment #8)
> The refactoring was added to SVN in 544682.
> There are one or two Gui elements that have not yet been fixed.

I noticed when I tested today that the "Clear All" did not work for listeners,
it didn't do anything. The "clear" on just an element worked as expected.
Comment 10 Sebb 2007-06-09 10:03:41 UTC
Found the problem - the search for Clearable items looks at the userObject, 
not the Gui; I had removed Clearable from ResultCollector as it did not appear 
to do anything...

Fixed in r54774; Run/Clear now works again.
Comment 11 Sebb 2007-06-10 10:44:53 UTC
Basically all done now; any problems please reopen with further details