On 25 January 2011 10:30, Barrie Treloar <[email protected]> wrote: > On Tue, Jan 25, 2011 at 10:49 AM, sebb <[email protected]> wrote: > >> On 24 January 2011 23:56, Barrie Treloar <[email protected]> wrote: >> > When I click "Add" in the "Send Parameters With the Request" panel for my >> > Java Request the new variable disappears if I save, or select another >> > element in the explorer and come back. >> > >> > I haven't noticed anything in the documentation that tells me how >> > JavaSamplerClient can get passed arguments. >> > (Only how to specify the default arguments) >> > >> > "HTTP Request" doesn't have the same problem, >> > I'm currently squirreling into the code to see why. >> > In the mean time I thought someone on the list could save me some time >> and >> > enlighten me. >> >> Sorry, but that does not work - never has, as far as I know. >> > > Hmm, not what I wanted to hear, but never mind, let's see if I can help fix > that. > > Cranking up the debugger against JMeter 2.4, > I notice that the JavaTestSamplerGui.modifyTestElement() is called and that > javaPanel.createTestElement() correctly contains my new name/value pairs for > the row in its propMap under the arguments key. > > Placing a watch on ArgumentsPanel.tableModel I can see that when I select > another node from the tree and then reselect my JavaSampler that > ArgumentsPanel.configure() is called and that the TestElement propsMap > contains my new row. > > But > JavaConfigGui.configure() > calls > - argsPanel.configure > then > - classnameCombo.setSelected > -> actionPerformed > - sets currArgs from the tableModel > - create newArgs as an empty Arguments > - sets testParams from the default parameter list > - then only if testParams is not empty (i.e. default parameter list) > does it check whether currArgs contains the keys from testParams, and if so > adds the key and currArgs' value to the newArgs. > - configures argsPanel with the newArgs. > > This means that instead of newArgs being a union of currArgs and testParams > it only contains testParams with updated values from currArgs. > > If I hack the saved xml to include my extra parameters I can see that they > are passed into the configuration. > But because of the above bug they are ignored. > > Watching JavaConfigGui.actionPerformed() it is currently invoked 4 times > when changing panels. > * > java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=comboBoxChanged,when=1295935629524,modifiers=] > on > javax.swing.JComboBox[,72,0,371x25,layout=javax.swing.plaf.metal.MetalComboBoxUI$MetalComboBoxLayoutManager,alignmentX=0.0,alignmentY=0.5,border=,flags=328,maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=my.fqn.Class] > * > java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=comboBoxChanged,when=1295935629524,modifiers=] > on > javax.swing.JComboBox[,72,0,371x25,layout=javax.swing.plaf.metal.MetalComboBoxUI$MetalComboBoxLayoutManager,alignmentX=0.0,alignmentY=0.5,border=,flags=328,maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=my.fqn.Class] > * > java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=comboBoxChanged,when=1295935629524,modifiers=] > on > javax.swing.JComboBox[,72,0,371x25,invalid,layout=javax.swing.plaf.metal.MetalComboBoxUI$MetalComboBoxLayoutManager,alignmentX=0.0,alignmentY=0.5,border=,flags=328,maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=my.fqn.Class] > * > java.awt.event.ActionEvent[ACTION_PERFORMED,cmd=comboBoxChanged,when=1295935629524,modifiers=] > on > javax.swing.JComboBox[,72,0,371x25,invalid,layout=javax.swing.plaf.metal.MetalComboBoxUI$MetalComboBoxLayoutManager,alignmentX=0.0,alignmentY=0.5,border=,flags=328,maximumSize=,minimumSize=,preferredSize=,isEditable=false,lightWeightPopupEnabled=true,maximumRowCount=8,selectedItemReminder=my.fqn.Class] > > The first 2 events are identical and the last 2 events are identical (and > they are identical to the first 2 except for including "invalid") > The duplicate events are probably because of the classnameCombo.setSelected > noted from above. > > > I could use some guidance here. > > QUESTION: > Should it arguments in the arguments panel be the union of the current > arguments and the default argument? > If I delete a default parameter then the union will add it back in. I think > if currArrgs is non-null it should use that, other wise use the default > arguments. > Is there any guidance on this?
Not that I know of. > Why isn't this provided out of the box via the framework? They are different from all the other samplers in that they (theoretically) allow one to provide additional parameters via the GUI. All other samplers define the parameters that they are expecting. The getDefaultParameters() method is what implementations use to initialise the GUI, and in general that's all the parameters they need. That is how the JavaTest and JavaSleep implementations work. I suppose it would be possible to write an implementation that could handle additional arbitrary parameters, but I'm not aware of one that uses this. > QUESTION: > The first thing I'd like to do is add some unit tests to prove the problem > and then solve it. > Is there any guidance on writing unit tests for JMeter? No specific guidance, but there are plenty of existing tests. > Cheers > Barrie > p.s. Tomorrow is International Ausrtalia day so there is no hacking for me. > But if I can get some guidance and can get cracking Thursday. > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

