View Javadoc

1   /*
2       Jameleon - An automation testing tool..
3       Copyright (C) 2003 Christian W. Hargraves (engrean@hotmail.com)
4       
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19  package net.sf.jameleon;
20  
21  import org.apache.log4j.Logger;
22  /***
23   * Iterates over all nested tags one time per row of a CSV file.
24   * The name of the CSV file is based on the <code>testEnvironment</code>, <code>organization</code>, and the 
25   * <code>name</code> attributes. The directory structure, then follows the <code>testEnvironment</code> 
26   * then inside that directory the <code>organization</code> if set. The file name matches the name set in 
27   * the csv attribute.
28   * 
29   * For example, to execute the opening of an application and doing something <b>n</b> number of times:
30   * <pre><source>
31   * &lt;testcase xmlns="jelly:jameleon"&gt;
32   *   &lt;csv name="some_file_name_without_extension"&gt;
33   *     &lt;some-session application="someApp" beginSession="true"&gt;
34   *       &lt;some-tag-that-uses-context-variables
35   *           functionId="Verify successful navigation, using a different variable."/&gt;
36   *     &lt;/some-session&gt;
37   *   &lt;/csv&gt;
38   * &lt;/testcase&gt;
39   * </source></pre>
40   * 
41   * Maybe opening the application <b>n</b> number of times takes too long, but
42   * each of the scenarios still need to be executed. Try putting the csv tag inside
43   * the session tag:
44   * <pre><source>
45   * &lt;testcase xmlns="jelly:jameleon"&gt;
46   *   &lt;some-session application="someApp" beginSession="true"&gt;
47   *     &lt;csv name="some_file_name_without_extension"&gt;
48   *       &lt;some-tag-that-uses-context-variables
49   *           functionId="Verify successful navigation, using a different variable."/&gt;
50   *     &lt;/csv&gt;
51   *   &lt;/some-session&gt;
52   * &lt;/testcase&gt;
53   * </source></pre>
54   * 
55   *
56   * All values that are not defined in a CSV file will be considered 'null'. To define an empty String,
57   * simply define the value as <b>&quot;&quot;</b>.
58   * For example:
59   * <pre><source>
60   * var1,var2,var3
61   * one,"",</source></pre>
62   * In the above example, var2 will be an empty string and var3 will be null.
63   * @jameleon.function name="csv"
64   */
65  public class CsvTag extends AbstractCsvTag {
66  
67      /***
68       * Gets the logger used for this tag
69       * @return the logger used for this tag.
70       */
71      protected Logger getLogger(){
72          return Logger.getLogger(CsvTag.class.getName());
73      }
74  
75      /***
76       * Gets the trace message when the execution is beginning and ending.
77       * The message displayed will already start with BEGIN: or END:
78       * @return the trace message when the execution is just beginning and ending.
79       */
80      protected String getTagTraceMsg(){
81          return "parsing " + getCsvFile();
82      }
83  
84      /***
85       * Describe the tag when error messages occur.
86       * The most appropriate message might be the tag name itself.
87       * @return A brief description of the tag or the tag name itself.
88       */
89      public String getTagDescription(){
90          return "csv tag";
91      }
92  
93  }