sebb        2004/10/08 15:38:35

  Modified:    src/components/org/apache/jmeter/assertions Tag: rel-2_0
                        BeanShellAssertion.java
  Log:
  Add init file if present. Make log available to script
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.3.2.2   +35 -16    
jakarta-jmeter/src/components/org/apache/jmeter/assertions/BeanShellAssertion.java
  
  Index: BeanShellAssertion.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/components/org/apache/jmeter/assertions/BeanShellAssertion.java,v
  retrieving revision 1.3.2.1
  retrieving revision 1.3.2.2
  diff -u -r1.3.2.1 -r1.3.2.2
  --- BeanShellAssertion.java   5 Jun 2004 14:44:28 -0000       1.3.2.1
  +++ BeanShellAssertion.java   8 Oct 2004 22:38:35 -0000       1.3.2.2
  @@ -26,6 +26,7 @@
      
   import org.apache.jmeter.samplers.SampleResult;
   import org.apache.jmeter.testelement.AbstractTestElement;
  +import org.apache.jmeter.util.JMeterUtils;
   import org.apache.jorphan.logging.LoggingManager;
   import org.apache.jorphan.util.JOrphanUtils;
   import org.apache.log.Logger;
  @@ -44,12 +45,29 @@
        public static final String SCRIPT     = "BeanShellAssertion.query"; 
//$NON-NLS-1$
        public static final String PARAMETERS = "BeanShellAssertion.parameters"; 
//$NON-NLS-1$
   
  +     // can be specified in jmeter.properties
  +     public static final String INIT_FILE = "beanshell.assertion.init"; 
//$NON-NLS-1$
  +
       private Interpreter bshInterpreter;
        
        public BeanShellAssertion()
        {
  +             String init="";
                try{
                        bshInterpreter = new Interpreter();
  +                     bshInterpreter.set("log",log);  //$NON-NLS-1$
  +                     init = JMeterUtils.getPropDefault(INIT_FILE,null);
  +                     if (init != null)
  +                     {
  +                             try
  +                             {
  +                                      bshInterpreter.source(null);
  +                             } catch (IOException e){
  +                                     log.warn("Error processing init file "+init+" 
"+e);
  +                             } catch (Exception e){
  +                                     log.warn("Error processing init file "+init+" 
"+e);
  +                             }
  +                     }
                } catch (NoClassDefFoundError e){
                        bshInterpreter=null;
                }
  @@ -82,23 +100,24 @@
                String request=getScript();
                String fileName=getFilename();
   
  -                     bshInterpreter.set("FileName",getFilename());
  -                     bshInterpreter.set("Parameters",getParameters());// as a 
single line
  -                     
bshInterpreter.set("bsh.args",JOrphanUtils.split(getParameters()," "));
  +                     bshInterpreter.set("FileName",getFilename());//$NON-NLS-1$
  +                     bshInterpreter.set("Parameters",getParameters());// as a 
single line $NON-NLS-1$
  +                     bshInterpreter.set("bsh.args",//$NON-NLS-1$
  +                                     JOrphanUtils.split(getParameters()," 
"));//$NON-NLS-1$
                        
  -                     bshInterpreter.set("Response",response);// Raw access to the 
response
  -                     bshInterpreter.set("ResponseData",response.getResponseData());
  -                     bshInterpreter.set("ResponseCode",response.getResponseCode());
  -                     
bshInterpreter.set("ResponseMessage",response.getResponseMessage());
  -                     
bshInterpreter.set("ResponseHeaders",response.getResponseHeaders());
  -                     
bshInterpreter.set("RequestHeaders",response.getRequestHeaders());
  -                     bshInterpreter.set("SampleLabel",response.getSampleLabel());
  -                     bshInterpreter.set("SamplerData",response.getSamplerData());
  -                     bshInterpreter.set("Successful",response.isSuccessful());
  +                     bshInterpreter.set("Response",response);// Raw access to the 
response //$NON-NLS-1$
  +                     
bshInterpreter.set("ResponseData",response.getResponseData());//$NON-NLS-1$
  +                     
bshInterpreter.set("ResponseCode",response.getResponseCode());//$NON-NLS-1$
  +                     
bshInterpreter.set("ResponseMessage",response.getResponseMessage());//$NON-NLS-1$
  +                     
bshInterpreter.set("ResponseHeaders",response.getResponseHeaders());//$NON-NLS-1$
  +                     
bshInterpreter.set("RequestHeaders",response.getRequestHeaders());//$NON-NLS-1$
  +                     
bshInterpreter.set("SampleLabel",response.getSampleLabel());//$NON-NLS-1$
  +                     
bshInterpreter.set("SamplerData",response.getSamplerData());//$NON-NLS-1$
  +                     
bshInterpreter.set("Successful",response.isSuccessful());//$NON-NLS-1$
   
                        // The following are used to set the Result details on return 
from the script:
  -                     bshInterpreter.set("FailureMessage","");
  -                     bshInterpreter.set("Failure",false);
  +                     bshInterpreter.set("FailureMessage","");//$NON-NLS-1$ 
//$NON-NLS-2$
  +                     bshInterpreter.set("Failure",false);//$NON-NLS-1$
   
                        //Object bshOut;
                        
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to