01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.providers.dao.cache;
17:
18: import junit.framework.TestCase;
19:
20: import org.acegisecurity.GrantedAuthority;
21: import org.acegisecurity.GrantedAuthorityImpl;
22:
23: import org.acegisecurity.userdetails.User;
24:
25: /**
26: * Tests {@link NullUserCache}.
27: *
28: * @author Ben Alex
29: * @version $Id: NullUserCacheTests.java 1496 2006-05-23 13:38:33Z benalex $
30: */
31: public class NullUserCacheTests extends TestCase {
32: //~ Constructors ===================================================================================================
33:
34: public NullUserCacheTests() {
35: super ();
36: }
37:
38: public NullUserCacheTests(String arg0) {
39: super (arg0);
40: }
41:
42: //~ Methods ========================================================================================================
43:
44: private User getUser() {
45: return new User("john", "password", true, true, true, true,
46: new GrantedAuthority[] {
47: new GrantedAuthorityImpl("ROLE_ONE"),
48: new GrantedAuthorityImpl("ROLE_TWO") });
49: }
50:
51: public static void main(String[] args) {
52: junit.textui.TestRunner.run(NullUserCacheTests.class);
53: }
54:
55: public final void setUp() throws Exception {
56: super .setUp();
57: }
58:
59: public void testCacheOperation() throws Exception {
60: NullUserCache cache = new NullUserCache();
61: cache.putUserInCache(getUser());
62: assertNull(cache.getUserFromCache(null));
63: cache.removeUserFromCache(null);
64: }
65: }
|