KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > ac > file > FileRoleTest


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: FileRoleTest.java 42625 2004-03-04 15:45:03Z egli $ */
19
20 package org.apache.lenya.ac.file;
21
22 import java.io.File JavaDoc;
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     /**
30      * Constructor for FileRoleTest.
31      * @param arg0 The test to execute.
32      */

33     public FileRoleTest(String JavaDoc arg0) {
34         super(arg0);
35     }
36
37     /**
38      * DOCUMENT ME!
39      *
40      * @param args DOCUMENT ME!
41      */

42     public static void main(String JavaDoc[] args) {
43         PublicationHelper.extractPublicationArguments(args);
44         junit.textui.TestRunner.run(FileRoleTest.class);
45     }
46
47     /**
48      * DOCUMENT ME!
49      *
50      * @throws AccessControlException DOCUMENT ME!
51      */

52     final public void testFileRole() throws AccessControlException {
53         String JavaDoc name = "test";
54         File JavaDoc configDir = getAccreditablesDirectory();
55         FileRole role = new FileRole(configDir, name);
56         role.save();
57
58         File JavaDoc path = null;
59         path = FileRoleManager.instance(configDir).getConfigurationDirectory();
60
61         File JavaDoc roleFile = new File JavaDoc(path, name + FileRoleManager.SUFFIX);
62         assertNotNull(roleFile);
63         assertTrue(roleFile.exists());
64     }
65
66     /**
67      * DOCUMENT ME!
68      *
69      * @throws AccessControlException DOCUMENT ME!
70      */

71     final public void testSave() throws AccessControlException {
72         File JavaDoc configDir = getAccreditablesDirectory();
73         String JavaDoc name = "test";
74         FileRole role = new FileRole(configDir, name);
75         role.save();
76
77         File JavaDoc path = null;
78         path = FileRoleManager.instance(configDir).getConfigurationDirectory();
79
80         File JavaDoc roleFile = new File JavaDoc(path, name + FileRoleManager.SUFFIX);
81         assertNotNull(roleFile);
82         assertTrue(roleFile.exists());
83     }
84
85     /**
86      * DOCUMENT ME!
87      */

88     final public void testGetId() {
89         String JavaDoc id = "test";
90         File JavaDoc configDir = getAccreditablesDirectory();
91         FileRole role = new FileRole(configDir, id);
92         assertTrue(role.getId().equals(id));
93     }
94
95     /**
96      * Test for boolean equals(Object)
97      */

98     final public void testEqualsObject() {
99         String JavaDoc name = "test";
100         File JavaDoc 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