001: /**
002: * $Id: FileDynamicCommunityTest.java,v 1.4 2007/01/26 03:47:55 portalbld Exp $
003: * Copyright 2005 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.community.mc.test;
014:
015: import java.util.Collections;
016: import java.util.HashSet;
017: import junit.framework.*;
018: import java.util.*;
019: import java.util.regex.*;
020:
021: import com.sun.portal.community.mc.*;
022: import com.sun.portal.community.mc.ConfigTable.ConfigKey;
023: import com.sun.portal.community.mc.impl.Debug;
024:
025: public abstract class FileDynamicCommunityTest extends TestCase {
026: protected static final String ROLE1_VISITOR_DP = "*** role1 visitor ***";
027: protected static final String ROLE1_MEMBER_DP = "*** role1 member ***";
028: protected static final String ROLE1_OWNER_DP = "*** role1 owner ***";
029:
030: protected ConfigKey role1VisitorCk;
031: protected ConfigKey role1MemberCk;
032: protected ConfigKey role1OwnerCk;
033:
034: protected CMCPrincipal role1Cp;
035: protected CMCNode role1Node;
036: protected CMCPrincipal role2Cp;
037: protected CMCNode role2Node;
038:
039: protected String xUserName;
040: protected String yUserName;
041: protected String zUserName;
042:
043: protected CMCUser xUser;
044:
045: public FileDynamicCommunityTest(String testName) {
046: super (testName);
047: }
048:
049: protected void setUp() throws java.lang.Exception {
050: super .setUp();
051: Debug.log("FileDynamicCommunityTest", "setUp", "called");
052:
053: role1Cp = new CMCPrincipal("filedynamic", "role1." + getName());
054: role2Cp = new CMCPrincipal("filedynamic", "role2." + getName());
055: xUserName = "xUser." + getName();
056: yUserName = "yUser." + getName();
057: zUserName = "zUser." + getName();
058:
059: role1VisitorCk = new ConfigKey(role1Cp,
060: CMCRolePrincipal.VISITOR_ROLE);
061: role1MemberCk = new ConfigKey(role1Cp,
062: CMCRolePrincipal.MEMBER_ROLE);
063: role1OwnerCk = new ConfigKey(role1Cp,
064: CMCRolePrincipal.OWNER_ROLE);
065:
066: try {
067: role1Node = CMCFactory.getInstance().getCMCNode(role1Cp);
068: role2Node = CMCFactory.getInstance().getCMCNode(role2Cp);
069: xUser = CMCFactory.getInstance().getCMCUser(xUserName);
070: } catch (CMCException ce) {
071: Debug.log("FileDynamicCommunityUserTest", "setUp", ce);
072: fail(ce.getMessage());
073: }
074: }
075:
076: protected void tearDown() throws java.lang.Exception {
077: super .tearDown();
078: Debug.log("FileDynamicCommunityTest", "tearDown", "called");
079: }
080:
081: public void createNodes() throws CMCException {
082: Debug.log("FileDynamicCommunityTest", "createNode", "called");
083: role1Node.create();
084: role2Node.create();
085: }
086:
087: public void addUsers() throws CMCException {
088: Debug.log("FileDynamicCommunityTest", "addUsers", "called");
089:
090: Set users = new HashSet();
091: users.add(xUserName);
092: role1Node.addUsers(users, CMCRolePrincipal.VISITOR_ROLE);
093:
094: users.clear();
095: users.add(yUserName);
096: users.add(zUserName);
097: role1Node.addUsers(users, CMCRolePrincipal.MEMBER_ROLE);
098:
099: users.clear();
100: users.add(zUserName);
101: role1Node.addUsers(users, CMCRolePrincipal.OWNER_ROLE);
102: }
103:
104: public void addRoles() throws CMCException {
105: Debug.log("FileDynamicCommunityTest", "addRoles", "called");
106: role1Node.addRole(CMCRolePrincipal.DISABLED_ROLE);
107: role2Node.addRole(CMCRolePrincipal.DISABLED_ROLE);
108: }
109:
110: public void removeRoles() throws CMCException {
111: Debug.log("FileDynamicCommunityTest", "removeRoles", "called");
112: role1Node.removeRole(CMCRolePrincipal.DISABLED_ROLE);
113: }
114:
115: public void removeNodes() throws CMCException {
116: Debug.log("FileDynamicCommunityTest", "testRemove", "called");
117: role1Node.remove();
118: role2Node.remove();
119: }
120:
121: public void setDPDocuments() throws CMCException {
122: Debug.log("FileDynamicCommunityTest", "setDPDocuments",
123: "called");
124:
125: ConfigTable dpDocs = new ConfigTable();
126:
127: dpDocs.put(role1VisitorCk, ROLE1_VISITOR_DP);
128: dpDocs.put(role1MemberCk, ROLE1_MEMBER_DP);
129: dpDocs.put(role1OwnerCk, ROLE1_OWNER_DP);
130:
131: role1Node.setDPDocuments(dpDocs);
132: }
133: }
|