📄 testorganizationalunits.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/test/org/opencms/security/TestOrganizationalUnits.java,v $
* Date : $Date: 2007-08-13 16:30:12 $
* Version: $Revision: 1.4 $
*
* This library is part of OpenCms -
* the Open Source Content Management System
*
* Copyright (c) 2002 - 2007 Alkacon Software GmbH (http://www.alkacon.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about Alkacon Software GmbH, please see the
* company website: http://www.alkacon.com
*
* For further information about OpenCms, please see the
* project website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.opencms.security;
import org.opencms.db.CmsDbConsistencyException;
import org.opencms.db.CmsDbEntryNotFoundException;
import org.opencms.file.CmsDataAccessException;
import org.opencms.file.CmsFolder;
import org.opencms.file.CmsGroup;
import org.opencms.file.CmsObject;
import org.opencms.file.CmsProject;
import org.opencms.file.CmsPropertyDefinition;
import org.opencms.file.CmsResource;
import org.opencms.file.CmsResourceFilter;
import org.opencms.file.CmsUser;
import org.opencms.file.CmsVfsException;
import org.opencms.file.CmsVfsResourceNotFoundException;
import org.opencms.lock.CmsLockType;
import org.opencms.main.CmsException;
import org.opencms.main.CmsIllegalArgumentException;
import org.opencms.main.OpenCms;
import org.opencms.relations.CmsRelation;
import org.opencms.relations.CmsRelationFilter;
import org.opencms.test.OpenCmsTestCase;
import org.opencms.test.OpenCmsTestProperties;
import org.opencms.util.CmsUUID;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
/**
* Unit tests for operations with organizational units.<p>
*
* @author Michael Moossen
*
* @version $Revision: 1.4 $
*/
public class TestOrganizationalUnits extends OpenCmsTestCase {
/**
* Default JUnit constructor.<p>
*
* @param arg0 JUnit parameters
*/
public TestOrganizationalUnits(String arg0) {
super(arg0);
}
/**
* Returns all organizational unit dependent roles.<p>
*
* @param ouFqn the organizational unit
*
* @return all organizational unit dependent roles
*/
public static List getOuRoles(String ouFqn) {
List roles = new ArrayList();
Iterator itRoles = CmsRole.getSystemRoles().iterator();
while (itRoles.hasNext()) {
CmsRole role = (CmsRole)itRoles.next();
if (!role.isOrganizationalUnitIndependent()) {
roles.add(role.forOrgUnit(ouFqn));
}
}
return roles;
}
/**
* Test suite for this test class.<p>
*
* @return the test suite
*/
public static Test suite() {
OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH);
TestSuite suite = new TestSuite();
suite.setName(TestOrganizationalUnits.class.getName());
suite.addTest(new TestOrganizationalUnits("testRootOu"));
suite.addTest(new TestOrganizationalUnits("testRootRoles"));
suite.addTest(new TestOrganizationalUnits("testFirstLevelOu"));
suite.addTest(new TestOrganizationalUnits("testFirstLevelRoles"));
suite.addTest(new TestOrganizationalUnits("testDeeperLevelOu"));
suite.addTest(new TestOrganizationalUnits("testDeeperLevelRoles"));
suite.addTest(new TestOrganizationalUnits("testResourceAssociations"));
suite.addTest(new TestOrganizationalUnits("testPrincipalAssociations"));
suite.addTest(new TestOrganizationalUnits("testRoleInheritance"));
suite.addTest(new TestOrganizationalUnits("testParallelRoles"));
suite.addTest(new TestOrganizationalUnits("testUserLogin"));
suite.addTest(new TestOrganizationalUnits("testMembership"));
suite.addTest(new TestOrganizationalUnits("testPersistence"));
suite.addTest(new TestOrganizationalUnits("testDelete"));
suite.addTest(new TestOrganizationalUnits("testBadName"));
TestSetup wrapper = new TestSetup(suite) {
protected void setUp() {
setupOpenCms("simpletest", "/sites/default/");
}
protected void tearDown() {
removeOpenCms();
}
};
return wrapper;
}
/**
* Tests handling with a deeper level ou.<p>
*
* @throws Throwable if something goes wrong
*/
public void testBadName() throws Throwable {
CmsObject cms = getCmsObject();
echo("Trying to create an organizational unit with an illegal name");
String[] badNames = new String[] {"/abc abc", "/鋌c", "/de
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -