1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.context;
17
18 import junit.framework.TestCase;
19
20 import org.acegisecurity.Authentication;
21 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
22
23
24 /***
25 * Tests {@link SecurityContextImpl}.
26 *
27 * @author Ben Alex
28 * @version $Id: SecurityContextImplTests.java,v 1.2 2005/11/17 00:55:51 benalex Exp $
29 */
30 public class SecurityContextImplTests extends TestCase {
31
32
33 public SecurityContextImplTests() {
34 super();
35 }
36
37 public SecurityContextImplTests(String arg0) {
38 super(arg0);
39 }
40
41
42
43 public final void setUp() throws Exception {
44 super.setUp();
45 }
46
47 public static void main(String[] args) {
48 junit.textui.TestRunner.run(SecurityContextImplTests.class);
49 }
50
51 public void testEmptyObjectsAreEquals() {
52 SecurityContextImpl obj1 = new SecurityContextImpl();
53 SecurityContextImpl obj2 = new SecurityContextImpl();
54 assertTrue(obj1.equals(obj2));
55 }
56
57 public void testSecurityContextCorrectOperation() {
58 SecurityContext context = new SecurityContextImpl();
59 Authentication auth = new UsernamePasswordAuthenticationToken("marissa",
60 "koala");
61 context.setAuthentication(auth);
62 assertEquals(auth, context.getAuthentication());
63 assertTrue(context.toString().lastIndexOf("marissa") != -1);
64 }
65 }