1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.security.spi;
18
19 import java.security.Principal;
20
21 import org.apache.jetspeed.security.util.test.AbstractSecurityTestcase;
22
23 import junit.framework.Test;
24 import junit.framework.TestSuite;
25
26 /***
27 * <p>
28 * Unit testing for {@link GroupSecurityHandler}.
29 * </p>
30 *
31 * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
32 */
33 public class TestGroupSecurityHandler extends AbstractSecurityTestcase
34 {
35
36
37
38 /***
39 * @see junit.framework.TestCase#setUp()
40 */
41 protected void setUp() throws Exception
42 {
43 super.setUp();
44 }
45
46 /***
47 * @see junit.framework.TestCase#tearDown()
48 */
49 public void tearDown() throws Exception
50 {
51 super.tearDown();
52 }
53
54 /***
55 * <p>
56 * Constructs the suite.
57 * </p>
58 *
59 * @return The {@Test}.
60 */
61 public static Test suite()
62 {
63 return new TestSuite(TestGroupSecurityHandler.class);
64 }
65
66 /***
67 * <p>
68 * Test <code>getGroupPrincipal</code>.
69 * </p>
70 */
71 public void testGetGroupPrincipal() throws Exception
72 {
73 initGroup();
74 Principal principal = gsh.getGroupPrincipal("testusertogroup1");
75 assertNotNull(principal);
76 assertEquals("testusertogroup1", principal.getName());
77 destroyGroup();
78 }
79
80 /***
81 * <p>
82 * Initialize group test object.
83 * </p>
84 */
85 protected void initGroup() throws Exception
86 {
87 gms.addGroup("testusertogroup1");
88 }
89
90 /***
91 * <p>
92 * Destroy group test object.
93 * </p>
94 */
95 protected void destroyGroup() throws Exception
96 {
97 gms.removeGroup("testusertogroup1");
98 }
99
100 }