sebb        2005/08/10 07:28:31

  Modified:    src/functions/org/apache/jmeter/functions CSVRead.java
                        PackageTest.java
               xdocs/usermanual functions.xml
               xdocs    changes.xml
  Log:
  Allow "next" to be specified column number suffix in CSVRead - easier to code
  
  Revision  Changes    Path
  1.16      +12 -2     
jakarta-jmeter/src/functions/org/apache/jmeter/functions/CSVRead.java
  
  Index: CSVRead.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/functions/org/apache/jmeter/functions/CSVRead.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CSVRead.java      12 Jul 2005 20:50:39 -0000      1.15
  +++ CSVRead.java      10 Aug 2005 14:28:31 -0000      1.16
  @@ -112,6 +112,13 @@
                        return "";
                }
   
  +             boolean getNext = false;// Should we get the next line after 
this column?
  +             int idxNext;
  +             if ((idxNext=columnOrNext.indexOf("next"))!=-1) {
  +                     getNext=true;
  +                     columnOrNext=columnOrNext.substring(0,idxNext);
  +             }
  +
                try {
                        int columnIndex = Integer.parseInt(columnOrNext); // 
what column
                                                                                
                                                // is wanted?
  @@ -126,6 +133,9 @@
   
                log.debug("execute value: " + myValue);
   
  +             if (getNext) {
  +                     FileWrapper.endRow(fileName);
  +             }
                return myValue;
        }
   
  
  
  
  1.15      +29 -8     
jakarta-jmeter/src/functions/org/apache/jmeter/functions/PackageTest.java
  
  Index: PackageTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jmeter/src/functions/org/apache/jmeter/functions/PackageTest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- PackageTest.java  12 Jul 2005 20:50:39 -0000      1.14
  +++ PackageTest.java  10 Aug 2005 14:28:31 -0000      1.15
  @@ -71,6 +71,19 @@
                return cr;
        }
   
  +     // Create the CSVRead function and set its parameters.
  +     private static CSVRead setParams(String p1, String p2, String p3, 
String p4) throws Exception {
  +             CSVRead cr = new CSVRead();
  +             Collection parms = new LinkedList();
  +             parms.add(new CompoundVariable(p1));
  +             parms.add(new CompoundVariable(p2));
  +             parms.add(new CompoundVariable(p3));
  +             if (p4 != null)
  +                     parms.add(new CompoundVariable(p4));
  +             cr.setParameters(parms);
  +             return cr;
  +     }
  +
        // Create the StringFromFile function and set its parameters.
        private static StringFromFile SFFParams(String p1, String p2, String 
p3, String p4) throws Exception {
                StringFromFile sff = new StringFromFile();
  @@ -379,7 +392,7 @@
        }
   
        // Function objects to be tested
  -     private static CSVRead cr1, cr2, cr3, cr4, cr5, cr6;
  +     private static CSVRead cr1, cr2, cr3, cr4, cr5, cr6, cr7;
   
        // Helper class used to implement co-routine between two threads
        private static class Baton {
  @@ -488,22 +501,29 @@
                assertEquals("", cr6.execute(null, null));
                assertEquals("a2", cr5.execute(null, null));
   
  +             assertEquals("b2", cr7.execute(null, null));
  +             assertEquals("b3", cr7.execute(null, null));
        }
   
        public void CSVParams() throws Exception {
                try {
                        setParams(null, null);
  -                     fail("Should have failed");
  +                     fail("Should have failed with 0 params");
                } catch (InvalidVariableException e) {
                }
                try {
  -                     setParams(null, "");
  -                     fail("Should have failed");
  +                     setParams("", null);
  +                     fail("Should have failed with 1 param");
                } catch (InvalidVariableException e) {
                }
                try {
  -                     setParams("", null);
  -                     fail("Should have failed");
  +                     setParams("", "","",null);
  +                     fail("Should have failed with 3 params");
  +             } catch (InvalidVariableException e) {
  +             }
  +             try {
  +                     setParams("", "","","");
  +                     fail("Should have failed with 4 params");
                } catch (InvalidVariableException e) {
                }
        }
  @@ -515,6 +535,7 @@
                cr4 = setParams("testfiles/test.csv", "next");
                cr5 = setParams("", "0");
                cr6 = setParams("", "next");
  +             cr7 = setParams("testfiles/test.csv", "1next");
        }
   
        public void CSValias() throws Exception {
  
  
  
  1.22      +9 -6      jakarta-jmeter/xdocs/usermanual/functions.xml
  
  Index: functions.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/xdocs/usermanual/functions.xml,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- functions.xml     18 Jun 2005 02:17:26 -0000      1.21
  +++ functions.xml     10 Aug 2005 14:28:31 -0000      1.22
  @@ -335,19 +335,22 @@
        </p>
        <p>
        Each thread has its own internal pointer to its current row in the file 
array.
  -     When a thread first refers to the file it will be allocated the next 
free row in
  +     When a thread first refers to the file (or uses next) it will be 
allocated the next unread row in
        the array, so each thread will access a different row from all other 
threads.
  -     [Unless there are more threads than there are rows in the array.]
  +     When the end of the file is reached, it starts from the beginning again.
        </p>
   </description>
   
   <properties>
           <property name="File Name" required="Yes">The file (or *ALIAS) to 
read from</property>
           <property name="Column number" required="Yes">
  -             The column number in the file.
  -             0 = first column, 1 = second etc.
  -             "next" - go to next line of file.
  -             *ALIAS - open a file and assign it to the alias
  +             The column number in the file:
  +             <ul>
  +             <li>0 = first column, 1 = second etc.</li>
  +             <li>next or next() - go to next unread line of file.</li>
  +             <li>3next - extract 4th column, and go to next unread line of 
file.</li>
  +             <li>*ALIAS - open a file and assign it to the alias</li>
  +             </ul>
                </property>
   </properties>
   </component>
  
  
  
  1.38      +2 -1      jakarta-jmeter/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jmeter/xdocs/changes.xml,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- changes.xml       6 Aug 2005 17:19:14 -0000       1.37
  +++ changes.xml       10 Aug 2005 14:28:31 -0000      1.38
  @@ -55,6 +55,7 @@
   <li>How-to for JMS samplers</li>
   <li>Bug 35525 - Added Spanish localisation</li>
   <li>Bug 30379 - allow server.rmi.port to be overridden</li>
  +<li>CSVRead - allow "next" to be appended to column number</li>
   </ul>
   <h4>Bug fixes:</h4>
   <ul>
  
  
  

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

Reply via email to