1   /*
2    * Wallace IMAP Server
3    * Copyright (C) 2004  Robert Newson
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License
7    * as published by the Free Software Foundation; either version 2
8    * of the License, or (at your option) any later version.
9    *
10   * This program 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
13   * GNU General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License
16   * along with this program; 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.wallace;
20  
21  import junit.framework.Assert;
22  import junit.framework.TestCase;
23  
24  /***
25   * 
26   * 
27   * @author rnewson
28   */
29  public final class WallaceSessionTest extends TestCase {
30      
31      private WallaceSession session;
32  
33      protected void setUp() {
34          session = new WallaceSession();
35      }
36      
37      public void testSetUserCannotBeNull() {
38          try {
39              session.setUser(null);
40          } catch (AssertionError e) {
41              return;
42          }
43          fail("Expected assertion failure.");
44      }
45      
46      public void testGetStoreCannotBeNull() {
47          try {
48              session.getStore();
49          } catch (AssertionError e) {
50              return;
51          }
52          fail("Expected assertion failure.");
53      }
54      
55      public void testSetStoreCannotBeNull() {
56          try {
57              session.setStore(null);
58          } catch (AssertionError e) {
59              return;
60          }
61          fail("Expected assertion failure.");
62      }
63      
64      public void testGetUserCannotBeNull() {
65          try {
66              session.getUser();
67          } catch (AssertionError e) {
68              return;
69          }
70          fail("Expected assertion failure.");
71      }
72      
73      public void testGetUser() {
74          final WallaceUser user = new WallaceUser("user");
75          session.setUser(user);
76          Assert.assertSame(user, session.getUser());
77      }
78  
79      public void testSetStateCannotBeNull() {
80          try {
81              session.setState(null);
82          } catch (AssertionError e) {
83              return;
84          }
85          fail("Expected assertion failure.");
86      }
87      
88      public void testSetSessionHandlerCannotBeNull() {
89          try {
90              session.setSessionHandler(null);
91          } catch (AssertionError e) {
92              return;
93          }
94          fail("Expected assertion failure.");
95      }
96      
97      
98      public void testSetServerConfigCannotBeNull() {
99          try {
100             session.setServerConfig(null);
101         } catch (AssertionError e) {
102             return;
103         }
104         fail("Expected assertion failure.");
105     }
106 
107     public void testGetServerConfigCannotBeNull() {
108         try {
109             session.getServerConfig();
110         } catch (AssertionError e) {
111             return;
112         }
113         fail("Expected assertion failure.");
114     }
115     
116     public void testResponseCannotBeNull() {
117         try {
118             session.respond(null);
119         } catch (AssertionError e) {
120             return;
121         }
122         fail("Expected assertion failure.");
123     }
124 
125 }