sebb        2004/10/13 15:12:22

  Modified:    src/core/org/apache/jmeter/control Tag: rel-2_0
                        WhileController.java
  Log:
  Change LAST to mean check last sample on entry as well
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.4   +14 -11    
jakarta-jmeter/src/core/org/apache/jmeter/control/WhileController.java
  
  Index: WhileController.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/control/WhileController.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- WhileController.java      13 Oct 2004 00:52:05 -0000      1.1.2.3
  +++ WhileController.java      13 Oct 2004 22:12:22 -0000      1.1.2.4
  @@ -53,19 +53,23 @@
        * Evaluate the condition, which can be:
        * blank or LAST = was the last sampler OK?
        * otherwise, evaluate the condition
  +     * @param inLoop - called by nextIsNull (within loop)
        */
  -    private boolean conditionTrue()
  +    private boolean conditionTrue(boolean inLoop)
       {
        String cnd = getCondition();
        log.debug("Condition string:"+cnd);
        boolean res;
  -     if (cnd.length() == 0 || "LAST".equalsIgnoreCase(cnd)) {// $NON-NLS-1$
  +     // If blank, only check previous sample when in loop
  +     if ((inLoop && cnd.length() == 0) 
  +                     || "LAST".equalsIgnoreCase(cnd)) {// $NON-NLS-1$
                JMeterVariables threadVars = 
                        JMeterContextService.getContext().getVariables();
                // Use !false rather than true, so that null is treated as true 
                    res = 
!"false".equalsIgnoreCase(threadVars.get(JMeterThread.LAST_SAMPLE_OK));// $NON-NLS-1$
        } else {
  -             res = "true".equalsIgnoreCase(cnd);// $NON-NLS-1$
  +             // cnd may be blank if next() called us
  +             res = !"false".equalsIgnoreCase(cnd);// $NON-NLS-1$
        }
        log.debug("Condition value: "+res);
           return res;
  @@ -77,7 +81,7 @@
       protected Sampler nextIsNull() throws NextIsNullException
       {
           reInitialize();
  -        if (conditionTrue())
  +        if (conditionTrue(true))
           {
               return next();
           }
  @@ -97,15 +101,14 @@
        */
       public Sampler next()
       {
  -     // Don't enter if condition false 
  -        if("false".equalsIgnoreCase(getCondition()))// $NON-NLS-1$
  +        if(conditionTrue(false))// $NON-NLS-1$
           {
  -            reInitialize();
  -            return null;
  +            return super.next(); // OK to continue
           }
           else
           {
  -            return super.next();
  +            reInitialize(); // Don't even start the loop
  +            return null;
           }
       }
   
  
  
  

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

Reply via email to