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       This library is distributed in the hope that it will be useful,
10      but WITHOUT ANY WARRANTY; without even the implied warranty of
11      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12      Lesser General Public License for more details.
13      You should have received a copy of the GNU Lesser General Public
14      License along with this library; if not, write to the Free Software
15      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111AssertLevel.NO_FUNCTION07 USA
16  */
17  package net.sf.jameleon.bean;
18  import net.sf.jameleon.XMLable;
19  import java.util.LinkedList;
20  import java.util.List;
21  import java.util.Iterator;
22  /***
23   * This class represents a Session in a TestCase. This is currently used only for test case
24   * documentation generation
25   * A Session consists of:
26   * <ul>
27   *  <li>application - The application this session is opened for. REQUIRED.</li>
28   *  <li>organization - The organization this session will test for if any - OPTIONAL.</li> 
29   *  <li>functional points - A list of <code>FunctionalPoint</code>s executed in this Session - REQUIRED</li>
30   * </ul>
31   */
32  public class Session implements XMLable{
33      private static final long serialVersionUID = 1L;
34     /***
35       * The application this session is opened for
36       */
37      protected String application;
38      /***
39       * The organization this session will test for if any
40       */
41      protected String organization;
42      /***
43       * A list of <code>FunctionalPoint</code>s
44       */
45      protected List functionalPoints;
46      /***
47       * Default constructor only used to initialize variables
48       */
49      public Session() {
50          functionalPoints = new LinkedList();
51      }
52      /***
53       * Constructor to set the following parameters
54       * @param application - The application this session is opened for
55       * @param organization - The organization this session will test for if any
56       */
57      public Session(String application, String organization) {
58          this();
59          this.application = application;
60          this.organization = organization;
61      }
62      /***
63       * @return a list of <code>FunctionalPoint</code>s contained in this Session
64       */
65      public List getFunctionalPoints(){
66          return this.functionalPoints;
67      }
68      /***
69       * Adds a <code>FunctionalPoint</code> to the list of <code>FunctionalPoint</code>s under this Session
70       * @param fp - A <code>FunctionalPoint</code> under this Session
71       */
72      public void addFunctionalPoint(FunctionalPoint fp){
73          functionalPoints.add(fp);
74      }
75      /***
76       * @return The application this session is opened for
77       */
78      public String getApplication(){
79          return this.application;
80      }
81      /***
82       * Sets the application this session is opened for
83       * @param application - the application this session is opened for
84       */
85      public void setApplication(String application){
86          this.application = application;
87      }
88      /***
89       * @return The organization this session will test for if any
90       */
91      public String getOrganization(){
92          return this.organization;
93      }
94      /***
95       * Sets the organization this session will test for if any
96       * @param organization - the organization this session will test for if any
97       */
98      public void setOrganization(String organization){
99          this.organization = organization;
100     }
101     public String toXML(){
102         StringBuffer str = new StringBuffer();
103         str.append("\t<session>\n");
104         if (application != null && application.length() > 0) {
105             str.append("\t\t<application>").append(application).append("</application>\n");
106         }
107         if (organization != null && organization.length() > 0) {
108             str.append("\t\t<organization>").append(organization).append("</organization>\n");
109         }
110         Iterator it = functionalPoints.iterator();
111         while (it.hasNext()) {
112             str.append(((XMLable)it.next()).toXML());
113         }
114         str.append("\t</session>\n");
115         return str.toString();
116     }
117 }