01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software distributed under the License
12: * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13: * or implied. See the License for the specific language governing permissions and limitations under
14: * the License.
15: *
16: */
17:
18: package org.apache.lenya.ac.file;
19:
20: import java.io.File;
21:
22: import org.apache.lenya.ac.AccessControlException;
23: import org.apache.lenya.ac.impl.AbstractAccessControlTest;
24:
25: /**
26: * File role test.
27: *
28: * @version $Id: FileRoleTest.java 485769 2006-12-11 17:41:23Z andreas $
29: */
30: public class FileRoleTest extends AbstractAccessControlTest {
31:
32: /**
33: * DOCUMENT ME!
34: *
35: * @throws AccessControlException DOCUMENT ME!
36: */
37: final public void testFileRole() throws AccessControlException {
38: String name = "test";
39: File configDir = getAccreditablesDirectory();
40: FileRole role = new FileRole(getAccreditableManager()
41: .getRoleManager(), getLogger(), name);
42: role.save();
43:
44: File path = null;
45: path = FileRoleManager.instance(getAccreditableManager(),
46: configDir, getLogger()).getConfigurationDirectory();
47:
48: File roleFile = new File(path, name + FileRoleManager.SUFFIX);
49: assertNotNull(roleFile);
50: assertTrue(roleFile.exists());
51: }
52:
53: /**
54: * DOCUMENT ME!
55: *
56: * @throws AccessControlException DOCUMENT ME!
57: */
58: final public void testSave() throws AccessControlException {
59: File configDir = getAccreditablesDirectory();
60: String name = "test";
61: FileRole role = new FileRole(getAccreditableManager()
62: .getRoleManager(), getLogger(), name);
63: role.save();
64:
65: File path = null;
66: path = FileRoleManager.instance(getAccreditableManager(),
67: configDir, getLogger()).getConfigurationDirectory();
68:
69: File roleFile = new File(path, name + FileRoleManager.SUFFIX);
70: assertNotNull(roleFile);
71: assertTrue(roleFile.exists());
72: }
73:
74: /**
75: * DOCUMENT ME!
76: * @throws AccessControlException
77: */
78: final public void testGetId() throws AccessControlException {
79: String id = "test";
80: FileRole role = new FileRole(getAccreditableManager()
81: .getRoleManager(), getLogger(), id);
82: assertTrue(role.getId().equals(id));
83: }
84:
85: /**
86: * Test for boolean equals(Object)
87: * @throws AccessControlException
88: */
89: final public void testEqualsObject() throws AccessControlException {
90: String name = "test";
91: FileRole role1 = new FileRole(getAccreditableManager()
92: .getRoleManager(), getLogger(), name);
93: FileRole role2 = new FileRole(getAccreditableManager()
94: .getRoleManager(), getLogger(), name);
95: assertEquals(role1, role2);
96: }
97: }
|