1 17 18 19 20 package org.apache.lenya.ac.file; 21 22 import java.io.File ; 23 24 import org.apache.lenya.ac.AccessControlException; 25 import org.apache.lenya.ac.impl.AccessControlTest; 26 import org.apache.lenya.cms.PublicationHelper; 27 28 public class FileRoleTest extends AccessControlTest { 29 33 public FileRoleTest(String arg0) { 34 super(arg0); 35 } 36 37 42 public static void main(String [] args) { 43 PublicationHelper.extractPublicationArguments(args); 44 junit.textui.TestRunner.run(FileRoleTest.class); 45 } 46 47 52 final public void testFileRole() throws AccessControlException { 53 String name = "test"; 54 File configDir = getAccreditablesDirectory(); 55 FileRole role = new FileRole(configDir, name); 56 role.save(); 57 58 File path = null; 59 path = FileRoleManager.instance(configDir).getConfigurationDirectory(); 60 61 File roleFile = new File (path, name + FileRoleManager.SUFFIX); 62 assertNotNull(roleFile); 63 assertTrue(roleFile.exists()); 64 } 65 66 71 final public void testSave() throws AccessControlException { 72 File configDir = getAccreditablesDirectory(); 73 String name = "test"; 74 FileRole role = new FileRole(configDir, name); 75 role.save(); 76 77 File path = null; 78 path = FileRoleManager.instance(configDir).getConfigurationDirectory(); 79 80 File roleFile = new File (path, name + FileRoleManager.SUFFIX); 81 assertNotNull(roleFile); 82 assertTrue(roleFile.exists()); 83 } 84 85 88 final public void testGetId() { 89 String id = "test"; 90 File configDir = getAccreditablesDirectory(); 91 FileRole role = new FileRole(configDir, id); 92 assertTrue(role.getId().equals(id)); 93 } 94 95 98 final public void testEqualsObject() { 99 String name = "test"; 100 File configDir = getAccreditablesDirectory(); 101 FileRole role1 = new FileRole(configDir, name); 102 FileRole role2 = new FileRole(configDir, name); 103 assertEquals(role1, role2); 104 } 105 } 106 | Popular Tags |