1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
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 }