Yes sorry.

So I have a sample that looks like

public class TestSampler extends AbstractSampler implements TestListener {

  public final static String HOST = "TestSampler.remoteHost";


   public final void setHost(String newServer) {
            this.setProperty(HOST, newServer);
   }

   public final String getHost() {
            return getPropertyAsString(HOST);
   }
}

Now I would like to set this values based on a user defined variable config
above this sampler.
So in my GUI config class for this sampler I have


public class TestSamplerGui extends AbstractSamplerGui implements
ActionListener, ChangeListener {

   private final JLabeledTextField remoteHost = new JLabeledTextField(
"Remote host"); //$NON-NLS-1$

        @Override
   protected void configureTestElement(TestElement mc) {
           remoteHost.setText(mc.getPropertyAsString(TestSampler.HOST));
        }


    public TestElement createTestElement() {
        TestSampler  sampler = new TestSampler ();
        modifyTestElement(sampler);

        return sampler;
    }


        public void modifyTestElement(TestElement s) {
      TestSamplerGui sampler = (TestSamplerGui ) s;
      this.configureTestElement(sampler);
      sampler.setProperty(FIXProtocolMessageSampler.HOST,this.remoteHost
.getText());
         }
}

So the first time if you set the value for remote host on the front end
within the sampler gui it writes it to the .xml file. But when you load it
again
and try and update the host it just pulls the old value back because of the
configureTestElement() method.

This was copied from the FTPSampler on trunk


Regards


Ben CUTHBERT


Futures and Options
8 Canada Square,Canary Wharf,London,E14 5HQ,United Kingdom


__________________________________________________________


Phone.     +44 (0) 20 799 22192


Email.       [email protected]


__________________________________________________________


                                                                           
             Deepak Shetty                                                 
             <[email protected]                                            
             >                                                          To 
                                        JMeter Users List                  
             Apr 13 2010 17:11          <[email protected]>   
                                                                        cc 
             Mail Size: 9388                                               
                                                                   Subject 
                                        Re: User defined variables         
                                                                           
             Please respond to                                             
               "JMeter Users                                               
                   List"                                                   
             <jmeter-u...@jakar                                            
               ta.apache.org>                                              
                                                                           
                                                                           




Sorry I think i misunderstood your question.
You are writing a custom sampler and you have defined a field in it and you
want to pass in a variable?

regards
deepak

On Tue, Apr 13, 2010 at 8:58 AM, <[email protected]> wrote:

> I think it is something in the GUI Config class.
>
> Is there a template anywhere that I can base my GUI code off?
> Regards
>
>
>
>
>
> __________________________________________________________
>
>
>
>             Deepak Shetty
>             <[email protected]
>             >                                                          To
>                                        JMeter Users List
>             Apr 13 2010 16:55          <[email protected]>
>                                                                        cc
>             Mail Size: 7046
>                                                                   Subject
>                                        Re: User defined variables
>
>             Please respond to
>               "JMeter Users
>                   List"
>             <jmeter-u...@jakar
>               ta.apache.org>
>
>
>
>
>
>
> should have worked . There might be a case mismatch or whitespace or
> something in the UDV. if you have verified that then what is your exact
> Test
> Structure and definition?(also did you get any errors in jmeter.log)
>
> On Tue, Apr 13, 2010 at 2:49 AM, <[email protected]> wrote:
>
> >
> > All
> >
> > Could how do I get my sampler to access user defined variables. When I
> set
> > a UDV Config element inside my ThreadGroup and put ${SERVER} in one of
> the
> > text fields in my SamplerGUI
> > the sample gui just puts ${SERVER} in the Sampler variable. Am I
missing
> > something. Is there an example Sampler one could use.
> >
> >
> >
> >
> > -----------------------------------------
> > SAVE PAPER - THINK BEFORE YOU PRINT!
> >
> > This transmission has been issued by a member of the HSBC Group
> > "HSBC" for the information of the addressee only and should not be
> > reproduced and/or distributed to any other person. Each page
> > attached hereto must be read in conjunction with any disclaimer
> > which forms part of it. Unless otherwise stated, this transmission
> > is neither an offer nor the solicitation of an offer to sell or
> > purchase any investment. Its contents are based on information
> > obtained from sources believed to be reliable but HSBC makes no
> > representation and accepts no responsibility or liability as to its
> > completeness or accuracy.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
>
> -----------------------------------------
> SAVE PAPER - THINK BEFORE YOU PRINT!
>
> This transmission has been issued by a member of the HSBC Group
> "HSBC" for the information of the addressee only and should not be
> reproduced and/or distributed to any other person. Each page
> attached hereto must be read in conjunction with any disclaimer
> which forms part of it. Unless otherwise stated, this transmission
> is neither an offer nor the solicitation of an offer to sell or
> purchase any investment. Its contents are based on information
> obtained from sources believed to be reliable but HSBC makes no
> representation and accepts no responsibility or liability as to its
> completeness or accuracy.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-----------------------------------------
SAVE PAPER - THINK BEFORE YOU PRINT!

This transmission has been issued by a member of the HSBC Group
"HSBC" for the information of the addressee only and should not be
reproduced and/or distributed to any other person. Each page
attached hereto must be read in conjunction with any disclaimer
which forms part of it. Unless otherwise stated, this transmission
is neither an offer nor the solicitation of an offer to sell or
purchase any investment. Its contents are based on information
obtained from sources believed to be reliable but HSBC makes no
representation and accepts no responsibility or liability as to its
completeness or accuracy.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to