01: /*
02: * Created on 07/07/2005 21:28:45
03: */
04: package net.jforum;
05:
06: import java.util.HashMap;
07: import java.util.Map;
08:
09: import javax.servlet.http.Cookie;
10:
11: import junit.framework.TestCase;
12: import net.jforum.entities.UserSession;
13:
14: /**
15: * Tests the auto login feature
16: * @author Rafael Steil
17: * @version $Id: AutoLoginTest.java,v 1.4 2005/07/26 04:01:19 diegopires Exp $
18: */
19: public class AutoLoginTest extends TestCase {
20: public void testAutoLoginWithNullCookieExpectFail() {
21: ControllerUtils c = this .newControllerUtils();
22: c.checkAutoLogin(this .newUserSession());
23: }
24:
25: private UserSession newUserSession() {
26: return new UserSession() {
27: public void makeAnonymous() {
28: throw new RuntimeException("went anonymous");
29: }
30: };
31: }
32:
33: private ControllerUtils newControllerUtils() {
34: return new ControllerUtils() {
35: private Map cookiesMap = new HashMap();
36:
37: protected Cookie getCookieTemplate(String name) {
38: return (Cookie) this .cookiesMap.get(name);
39: }
40:
41: protected void addCookieTemplate(String name, String value) {
42: this .cookiesMap.put(name, new Cookie(name, value));
43: }
44:
45: };
46: }
47: }
|