KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > users > filesystem > GroupTest


1 /*
2 Copyright (c) 2003 eInnovation Inc. All rights reserved
3
4 This library is free software; you can redistribute it and/or modify it under the terms
5 of the GNU Lesser General Public License as published by the Free Software Foundation;
6 either version 2.1 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the GNU Lesser General Public License for more details.
11 */

12
13 package com.openedit.users.filesystem;
14
15 import com.openedit.users.BaseUserTest;
16 import com.openedit.users.Group;
17 import com.openedit.users.User;
18
19
20 /**
21  * This is an abstract test for {@link Group} implementations. Concrete {@link Group}s should
22  * subclass this testcase and add their own tests.
23  *
24  * @author Eric Galluzzo
25  */

26 public class GroupTest extends BaseUserTest
27 {
28     protected Group fieldGroup;
29     protected User fieldUser;
30
31     public GroupTest(String JavaDoc inName)
32     {
33         super(inName);
34     }
35
36     /**
37      * DOCUMENT ME!
38      *
39      * @throws Exception
40      */

41     public void hasPermission() throws Exception JavaDoc
42     {
43         assertTrue("Should have testpermission", fieldGroup.hasPermission("testpermission"));
44     }
45
46     /**
47      * DOCUMENT ME!
48      *
49      * @throws Exception
50      */

51     public void testAddPermission() throws Exception JavaDoc
52     {
53         fieldGroup.addPermission("newpermission");
54         assertEquals("Number of permissions", 2, fieldGroup.getPermissions().size());
55         assertTrue("Should now have newpermission", fieldGroup.hasPermission("newpermission"));
56     }
57
58
59     /**
60      * DOCUMENT ME!
61      *
62      * @throws Exception
63      */

64     public void testRemovePermission() throws Exception JavaDoc
65     {
66         fieldGroup.removePermission("testpermission");
67         assertEquals("Number of permissions", 0, fieldGroup.getPermissions().size());
68         assertTrue(
69             "Should not still have testpermission", !fieldGroup.hasPermission("testpermission"));
70     }
71
72
73
74     /*
75      * @see TestCase#setUp()
76      */

77     protected void setUp() throws Exception JavaDoc
78     {
79         fieldUserManager = createUserManager();
80         fieldUser = fieldUserManager.createUser("testuser", "testpwd");
81
82         fieldGroup = fieldUserManager.createGroup("testgroup");
83         fieldGroup.addPermission("testpermission");
84         fieldUser.addGroup(fieldGroup);
85         fieldUserManager.saveGroup(fieldGroup);
86     }
87
88     /*
89      * @see TestCase#tearDown()
90      */

91     protected void tearDown() throws Exception JavaDoc
92     {
93         deleteUserManager(fieldUserManager);
94     }
95 }
96
Popular Tags