1 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 26 public class GroupTest extends BaseUserTest 27 { 28 protected Group fieldGroup; 29 protected User fieldUser; 30 31 public GroupTest(String inName) 32 { 33 super(inName); 34 } 35 36 41 public void hasPermission() throws Exception 42 { 43 assertTrue("Should have testpermission", fieldGroup.hasPermission("testpermission")); 44 } 45 46 51 public void testAddPermission() throws Exception 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 64 public void testRemovePermission() throws Exception 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 77 protected void setUp() throws Exception 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 91 protected void tearDown() throws Exception 92 { 93 deleteUserManager(fieldUserManager); 94 } 95 } 96 | Popular Tags |