1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.wallace.commands;
20
21 import java.io.File;
22 import java.util.Properties;
23
24 import junit.framework.TestCase;
25 import net.sf.wallace.ServerResponse;
26 import net.sf.wallace.SessionHandler;
27 import net.sf.wallace.WallaceServerConfig;
28 import net.sf.wallace.WallaceSession;
29
30 /***
31 * This abstract class sets up the following objects for subclasses;
32 *
33 * netty Session WallaceSession WallaceServerConfig
34 *
35 * A mechanism to retrieve a response message.
36 *
37 * @author rnewson
38 */
39 public abstract class AbstractCommandTestCase extends TestCase {
40
41 protected WallaceSession wallaceSession;
42
43 protected WallaceServerConfig wallaceServerConfig;
44
45 protected ServerResponse serverResponse;
46
47 protected void setUp() {
48 wallaceServerConfig = new WallaceServerConfig();
49 wallaceServerConfig.setJavaMailProperties(new Properties());
50 wallaceServerConfig.setMailboxRootDirectory(new File(System.getProperty("java.io.tmpdir")));
51
52 final SessionHandler sessionHandler = new SessionHandler() {
53
54 public void respond(final ServerResponse newServerResponse) {
55 serverResponse = newServerResponse;
56 }
57
58 public void close() {
59
60 }
61 };
62
63 final WallaceSession newWallaceSession = new WallaceSession();
64 newWallaceSession.setSessionHandler(sessionHandler);
65 newWallaceSession.setServerConfig(wallaceServerConfig);
66 wallaceSession = newWallaceSession;
67 }
68
69 protected void tearDown() {
70 wallaceSession.close();
71 }
72
73 protected ServerResponse getResponse() {
74 return serverResponse;
75 }
76
77 }