sebb        2005/03/16 16:34:43

  Modified:    src/core/org/apache/jmeter/control Tag: rel-2_0 RunTime.java
  Log:
  Bug 33559 - now behaves like Loop Controller with OnceOnly
  Reset start-time each time so subsequent loops work OK
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.4   +28 -10    
jakarta-jmeter/src/core/org/apache/jmeter/control/RunTime.java
  
  Index: RunTime.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/control/RunTime.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- RunTime.java      13 Mar 2005 19:08:12 -0000      1.1.2.3
  +++ RunTime.java      17 Mar 2005 00:34:43 -0000      1.1.2.4
  @@ -36,6 +36,8 @@
       private final static String SECONDS = "RunTime.seconds";
       private volatile long startTime = 0;
   
  +     private int loopCount = 0; // for getIterCount
  +     
       public RunTime()
       {
       }
  @@ -84,17 +86,12 @@
   
       private boolean endOfLoop()
       {
  -             if (startTime == 0) startTime=System.currentTimeMillis();
           return System.currentTimeMillis()-startTime >= 1000*getRuntime();
       }
   
        public Sampler next()
        {
  -             if (endOfLoop()){
  -                     startTime=0; // Make sure it will be reset next time
  -                     reInitialize();
  -                     return null;
  -             }
  +             if (startTime == 0) startTime=System.currentTimeMillis();
                return super.next();
        }
       /* (non-Javadoc)
  @@ -105,8 +102,7 @@
           reInitialize();
           if (endOfLoop())
           {
  -                     startTime=0; // Make sure it will be reset next time
  -            //setDone(true);
  +            resetLoopCount();
               return null;
           }
           else
  @@ -115,4 +111,26 @@
           }
       }
   
  +     protected void incrementLoopCount()
  +     {
  +             loopCount++;
  +     }
  +     protected void resetLoopCount()
  +     {
  +             loopCount=0;
  +             startTime=0;
  +     }
  +     /*
  +      * This is needed for OnceOnly to work like other Loop Controllers
  +      */
  +     protected int getIterCount()
  +     {
  +             return loopCount + 1;
  +     }
  +     protected void reInitialize()
  +     {
  +             setFirst(true);
  +             resetCurrent();
  +             incrementLoopCount();
  +     }
   }
  \ No newline at end of file
  
  
  

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

Reply via email to