View Javadoc

1   /*
2    * Copyright (c) 2002 Peter Antman, Teknik i Media  <peter.antman@tim.se>
3    *
4    * $Id: BaseCase.java,v 1.1.1.1 2004/05/19 12:33:40 pra Exp $
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2 of the License, or (at your option) any later version
10   * 
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19   */
20  package org.backsource.alert.agent;
21  import java.util.List;
22  import java.util.Vector;
23  import java.util.Properties;
24  import java.util.StringTokenizer;
25  import java.io.InputStream;
26  
27  import junit.framework.TestCase;
28  
29  import org.apache.commons.logging.Log;
30  import org.apache.commons.logging.LogFactory;
31  
32  import org.backsource.alert.Agent;
33  import org.backsource.alert.PropertyUtil;
34  
35  /***
36   * A base class for Agents.
37   *
38   *<p>This class should be extended by agents. It should override setUp() to set up any of its own properties. An agent will be setup after instantiation by the AgentCase class. Sublclasses may acces the prop field, in the setUp method</p>
39   *
40   *
41   * @author <a href="mailto:pra@tim.se">Peter Antman</a>
42   * @version $Revision: 1.1.1.1 $
43   */
44  
45  public class BaseCase extends TestCase implements Agent{
46     static final Log log = LogFactory.getLog(BaseCase.class);
47     protected String agentName;
48     protected Properties prop = null;
49  
50     public BaseCase(String name) {
51        super(name);
52     }
53    
54     protected void setUp() throws Exception{
55        //prop = PropertyUtil.getProperties();
56        
57     }
58     /***
59      * Initialize the agent with a unique describing name and its properties.
60      */
61     public void initialize(String agentName, Properties prop) throws Exception {
62        this.agentName = agentName;
63        this.prop = prop;
64        log.debug("Got properties: " + prop);
65     }
66     
67     /***
68      * Get the name of the agent instance.
69      */
70     public String getAgentName() {
71        return agentName;
72     }
73     /***
74      * Get the properties connected to this particular instance of the agent.
75      */
76     public Properties getProperties() {
77        return prop;
78     } 
79  
80     /***
81      * Owerridden to add the agent name to the string.
82      */
83     public String toString() {
84        return agentName+": "+super.toString();
85     }
86  }// BaseCase