alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

jforum example source code file (AutoLoginTest.java)

This example jforum source code file (AutoLoginTest.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - jforum tags/keywords

autologintest, autologintest, controllerutils, controllerutils, cookie, cookie, hashmap, http, map, request, response, runtimeexception, servlet, string, testcase, usersession, usersession, util

The jforum AutoLoginTest.java source code

/*
 * Created on 07/07/2005 21:28:45
 */
package net.jforum;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.Cookie;

import junit.framework.TestCase;
import net.jforum.entities.UserSession;

/**
 * Tests the auto login feature
 * @author Rafael Steil
 * @version $Id: AutoLoginTest.java,v 1.4 2005/07/26 04:01:19 diegopires Exp $
 */
public class AutoLoginTest extends TestCase
{
	public void testAutoLoginWithNullCookieExpectFail()
	{
		ControllerUtils c = this.newControllerUtils();
		c.checkAutoLogin(this.newUserSession());
	}
	
	private UserSession newUserSession()
	{
		return new UserSession() {
			public void makeAnonymous() {
				throw new RuntimeException("went anonymous");
			}
		};
	}

	private ControllerUtils newControllerUtils()
	{
		return new ControllerUtils() {
			private Map cookiesMap = new HashMap();
			
			protected Cookie getCookieTemplate(String name) {
				return (Cookie)this.cookiesMap.get(name);
			}
			
			protected void addCookieTemplate(String name, String value) {
				this.cookiesMap.put(name, new Cookie(name, value));
			}
			
			
		};
	}
}

Other jforum examples (source code examples)

Here is a short list of links related to this jforum AutoLoginTest.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.