01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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: * @see junit.framework.TestCase#setUp()
37: */
38: protected void setUp() throws Exception {
39: super .setUp();
40: }
41:
42: /**
43: * @see junit.framework.TestCase#tearDown()
44: */
45: public void tearDown() throws Exception {
46: super .tearDown();
47: }
48:
49: /**
50: * <p>
51: * Constructs the suite.
52: * </p>
53: *
54: * @return The {@Test}.
55: */
56: public static Test suite() {
57: return new TestSuite(TestGroupSecurityHandler.class);
58: }
59:
60: /**
61: * <p>
62: * Test <code>getGroupPrincipal</code>.
63: * </p>
64: */
65: public void testGetGroupPrincipal() throws Exception {
66: initGroup();
67: Principal principal = gsh.getGroupPrincipal("testusertogroup1");
68: assertNotNull(principal);
69: assertEquals("testusertogroup1", principal.getName());
70: destroyGroup();
71: }
72:
73: /**
74: * <p>
75: * Initialize group test object.
76: * </p>
77: */
78: protected void initGroup() throws Exception {
79: gms.addGroup("testusertogroup1");
80: }
81:
82: /**
83: * <p>
84: * Destroy group test object.
85: * </p>
86: */
87: protected void destroyGroup() throws Exception {
88: gms.removeGroup("testusertogroup1");
89: }
90:
91: }
|