001: /**
002: * $Id: FileStatCommunityUserTest.java,v 1.3 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.HashSet;
016: import junit.framework.*;
017: import java.util.Set;
018: import com.sun.portal.community.mc.*;
019: import com.sun.portal.community.mc.impl.Debug;
020:
021: public class FileStatCommunityUserTest extends FileStatCommunityTest {
022: public FileStatCommunityUserTest(String testName) {
023: super (testName);
024: }
025:
026: protected void setUp() throws java.lang.Exception {
027: super .setUp();
028: Debug.log("FileStatCommunityUserTest", "setUp", "called");
029: }
030:
031: protected void tearDown() throws java.lang.Exception {
032: super .tearDown();
033: Debug.log("FileStatCommunityUserTest", "tearDown", "called");
034: }
035:
036: public static junit.framework.Test suite() {
037: junit.framework.TestSuite suite = new junit.framework.TestSuite(
038: FileStatCommunityUserTest.class);
039: return suite;
040: }
041:
042: public void testGetUserId() {
043: Debug.log("FileStatCommunityUserTest", "testGetUserId",
044: "called");
045:
046: String uid = xUser.getUserId();
047: assertNotNull(uid);
048: assertEquals(xUserName, uid);
049: }
050:
051: public void testGetMembership() {
052: Debug.log("FileStatCommunityUserTest", "testGetMembership",
053: "called");
054:
055: try {
056: Set all = xUser.getMembership();
057: assertEquals(2, all.size());
058: } catch (CMCException ce) {
059: Debug.log("FileStatCommunityUserTest", "testGetMembership",
060: ce);
061: fail(ce.getMessage());
062: }
063: }
064:
065: public void testGetMembershipByName() {
066: Debug.log("FileStatCommunityUserTest",
067: "testGetMembershipByName", "called");
068:
069: try {
070: Set all = xUser.getMembershipByName();
071: assertEquals(1, all.size());
072: } catch (CMCException ce) {
073: Debug.log("FileStatCommunityUserTest",
074: "testGetMembershipByName", ce);
075: fail(ce.getMessage());
076: }
077: }
078:
079: public void testGetMembershipByRole() {
080: Debug.log("FileStatCommunityUserTest",
081: "testGetMembershipByRole", "called");
082:
083: try {
084: Set all = xUser.getMembershipByRole();
085: assertEquals(1, all.size());
086: } catch (CMCException ce) {
087: Debug.log("FileStatCommunityUserTest",
088: "testGetMembershipByRole", ce);
089: fail(ce.getMessage());
090: }
091: }
092:
093: public void testGetAvailable() {
094: Debug.log("FileStatCommunityUserTest", "testGetAvailable",
095: "called");
096:
097: try {
098: Set avail = xUser.getAvailable();
099: assertEquals(1, avail.size());
100: } catch (CMCException ce) {
101: Debug.log("FileStatCommunityUserTest", "testGetAvailable",
102: ce);
103: fail(ce.getMessage());
104: }
105: }
106:
107: public void testHasRole() {
108: Debug.log("FileStatCommunityUserTest", "testHasRole", "called");
109:
110: try {
111: assertFalse(xUser.hasRole(orgCp,
112: CMCRolePrincipal.VISITOR_ROLE));
113: assertTrue(xUser.hasRole(orgCp,
114: CMCRolePrincipal.MEMBER_ROLE));
115: assertFalse(xUser.hasRole(orgCp,
116: CMCRolePrincipal.OWNER_ROLE));
117: assertTrue(xUser.hasRole(orgCp,
118: CMCRolePrincipal.DISABLED_ROLE));
119: } catch (CMCException ce) {
120: Debug.log("FileStatCommunityUserTest", "testHasRole", ce);
121: fail(ce.getMessage());
122: }
123: }
124:
125: public void testGetDPDocuments() {
126: Debug.log("FileStatCommunityUserTest", "testGetDPDocuments",
127: "called");
128:
129: try {
130: ConfigTable lastRead = new ConfigTable();
131: ConfigTable dpDocuments = xUser.getDPDocuments(lastRead);
132: assertEquals(1, dpDocuments.size());
133: } catch (CMCException ce) {
134: Debug.log("FileStatCommunityUserTest",
135: "testGetDPDocuments", ce);
136: fail(ce.getMessage());
137: }
138: }
139: }
|