Source code: openfuture/bugbase/test/login/JspLoginTestCase.java
1 package openfuture.bugbase.test.login;
2 /*
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.<p>
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.<p>
12 *
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 02111-1307 USA<br>
16 * http://www.gnu.org/copyleft/lesser.html
17 */
18
19 import com.meterware.httpunit.WebConversation;
20 import openfuture.bugbase.domain.User;
21 import openfuture.bugbase.model.JspConstants;
22 import openfuture.bugbase.test.common.JspBaseTestCase;
23 import org.apache.cactus.WebRequest;
24
25 // Configuration Management Information:
26 // -------------------------------------
27 // $Id: JspLoginTestCase.java,v 1.1 2001/10/31 23:00:17 wreissen Exp $
28 //
29 // Version History:
30 // ----------------
31 // $Log: JspLoginTestCase.java,v $
32 // Revision 1.1 2001/10/31 23:00:17 wreissen
33 // initial version
34 //
35 //
36 // ***********************************************************************************
37 /**
38 * Try simple login and logoff to and from bug base.<p>
39 *
40 *
41 * Created: Mon Oct 29 21:36:31 2001
42 *
43 * @author <a href="mailto:wolfgang@openfuture.de">Wolfgang Reissenberger</a>
44 * @version $Revision: 1.1 $
45 */
46
47 public class JspLoginTestCase extends JspBaseTestCase {
48
49 /**
50 * Creates a new <code>JspLoginTestCase</code> instance.
51 *
52 * @param name test case name
53 */
54 public JspLoginTestCase(String name) {
55 super(name);
56 }
57
58 /**
59 * Login into Bug Base using HTTPUnit
60 *
61 * @param request web request to continue
62 * @exception Exception if an error occurs
63 */
64 public void beginLogin(WebRequest request) throws Exception {
65
66 loginPage(new WebConversation(), request, "Login.jsp", true);
67 }
68
69 /**
70 * Check, if {@link openfuture.bugbase.model.JspConstants#USER this
71 * is the correct user}.
72 *
73 * @exception Exception if an error occurs
74 */
75 public void testLogin() throws Exception {
76 assertNotNull("No user set in the session!", session.getAttribute(JspConstants.USER));
77 User user = (User) session.getAttribute(JspConstants.USER);
78 assertEquals("Wrong user!", user.getUserid(),
79 getProperties().getProperty("openfuture.bugbase.test.userid"));
80
81 assertNotNull("No project set!", session.getAttribute(JspConstants.USER));
82 }
83
84
85
86
87 /**
88 * Logoff from Bug Base using HTTPUnit. First we login and then
89 * we immediately log off again.
90 *
91 * @param request web request to continue
92 * @exception Exception if an error occurs
93 */
94 public void beginLogoff(WebRequest request) throws Exception {
95 WebConversation wc = new WebConversation();
96
97 // first we login
98 loginPage(wc, request, "index.jsp", true);
99
100 // and now we log off again...
101 logoffPage(wc, request, "index.jsp");
102 }
103
104 /**
105 * Check, if the {@link openfuture.bugbase.model.JspConstants#USER user attribute}
106 * is cleared.
107 *
108 * @exception Exception if an error occurs
109 */
110 public void testLogoff() throws Exception {
111 assertNull("User still set in the session!", session.getAttribute(JspConstants.USER));
112 }
113
114
115 } // JspLoginTestCase