1   /* 
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     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     
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 }