1 17 18 19 20 package org.apache.lenya.ac.impl; 21 22 import java.io.File ; 23 24 import org.apache.lenya.ac.AccessControlException; 25 import org.apache.lenya.ac.Role; 26 import org.apache.lenya.ac.file.FileRole; 27 import org.apache.lenya.ac.file.FileRoleManager; 28 import org.apache.lenya.cms.PublicationHelper; 29 30 public class RoleManagerTest extends AccessControlTest { 31 35 public RoleManagerTest(String arg0) { 36 super(arg0); 37 } 38 39 44 public static void main(String [] args) { 45 PublicationHelper.extractPublicationArguments(args); 46 junit.textui.TestRunner.run(RoleManagerTest.class); 47 } 48 49 54 final public void testInstance() throws AccessControlException { 55 File configDir = getAccreditablesDirectory(); 56 FileRoleManager manager = FileRoleManager.instance(configDir); 57 assertNotNull(manager); 58 59 FileRoleManager anotherManager = FileRoleManager.instance(configDir); 60 assertNotNull(anotherManager); 61 assertEquals(manager, anotherManager); 62 } 63 64 67 final public void testGetRoles() { 68 } 69 70 75 final public void testAddRole() throws AccessControlException { 76 File configDir = getAccreditablesDirectory(); 77 String name = "test"; 78 FileRoleManager manager = null; 79 manager = FileRoleManager.instance(configDir); 80 assertNotNull(manager); 81 Role role = new FileRole(manager.getConfigurationDirectory(), name); 82 manager.add(role); 83 84 assertTrue(manager.getRoles().length > 0); 85 } 86 87 91 final public void testRemoveRole() throws AccessControlException { 92 File configDir = getAccreditablesDirectory(); 93 String name = "test2"; 94 Role role = new FileRole(configDir, name); 95 FileRoleManager manager = null; 96 97 try { 98 manager = FileRoleManager.instance(configDir); 99 } catch (AccessControlException e) { 100 e.printStackTrace(); 101 } 102 103 assertNotNull(manager); 104 105 Role[] roles = manager.getRoles(); 106 int roleCountBefore = roles.length; 107 108 manager.add(role); 109 manager.remove(role); 110 111 roles = manager.getRoles(); 112 int roleCountAfter = roles.length; 113 114 assertEquals(roleCountBefore, roleCountAfter); 115 } 116 } 117 | Popular Tags |