001: /**
002: * $Id: AMCommunityUserTest.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 AMCommunityUserTest extends AMCommunityTest {
022: public AMCommunityUserTest(String testName) {
023: super (testName);
024: }
025:
026: protected void setUp() throws java.lang.Exception {
027: super .setUp();
028: Debug.log("AMCommunityUserTest", "setUp", "called");
029: }
030:
031: protected void tearDown() throws java.lang.Exception {
032: super .tearDown();
033: Debug.log("AMCommunityUserTest", "tearDown", "called");
034: }
035:
036: public static junit.framework.Test suite() {
037: junit.framework.TestSuite suite = new junit.framework.TestSuite(
038: AMCommunityUserTest.class);
039: return suite;
040: }
041:
042: public void testGetUserId() {
043: Debug.log("AMCommunityUserTest", "testGetUserId", "called");
044:
045: String uid = xUser.getUserId();
046: assertNotNull(uid);
047: assertEquals(xUserName, uid);
048: }
049:
050: public void testGetMembership() {
051: Debug.log("AMCommunityUserTest", "testGetMembership", "called");
052:
053: try {
054: // nothing much
055: // just make sure the call goes through
056: Set all = xUser.getMembership();
057: assertNotNull(all);
058: } catch (CMCException ce) {
059: Debug.log("AMCommunityUserTest", "testGetMembership", ce);
060: fail(ce.getMessage());
061: }
062: }
063:
064: public void testGetAvailable() {
065: Debug.log("AMCommunityUserTest", "testGetAvailable", "called");
066:
067: try {
068: // nothing much
069: // just make sure the call goes through
070: Set avail = xUser.getAvailable();
071: assertNotNull(avail);
072: } catch (CMCException ce) {
073: Debug.log("AMCommunityUserTest", "testGetAvailable", ce);
074: fail(ce.getMessage());
075: }
076: }
077:
078: public void testHasRole() {
079: Debug.log("AMCommunityUserTest", "testHasRole", "called");
080:
081: try {
082: assertFalse(xUser.hasRole(orgCp,
083: CMCRolePrincipal.VISITOR_ROLE));
084: assertTrue(xUser.hasRole(orgCp,
085: CMCRolePrincipal.MEMBER_ROLE));
086: assertFalse(xUser.hasRole(orgCp,
087: CMCRolePrincipal.OWNER_ROLE));
088: assertFalse(xUser.hasRole(orgCp,
089: CMCRolePrincipal.INVITED_ROLE));
090: assertFalse(xUser.hasRole(orgCp,
091: CMCRolePrincipal.REJECTED_ROLE));
092: assertFalse(xUser.hasRole(orgCp,
093: CMCRolePrincipal.PENDING_ROLE));
094: assertFalse(xUser.hasRole(orgCp,
095: CMCRolePrincipal.BANNED_ROLE));
096:
097: } catch (CMCException ce) {
098: Debug.log("AMCommunityUserTest", "testHasRole", ce);
099: fail(ce.getMessage());
100: }
101: }
102:
103: public void testGetDPDocuments() {
104: Debug
105: .log("AMCommunityUserTest", "testGetDPDocuments",
106: "called");
107:
108: try {
109: // nothing much
110: // just make sure the call goes through
111: ConfigTable lastRead = new ConfigTable();
112: ConfigTable dpDocuments = xUser.getDPDocuments(lastRead);
113: assertNotNull(dpDocuments);
114: } catch (CMCException ce) {
115: Debug.log("AMCommunityUserTest", "testGetDPDocuments", ce);
116: fail(ce.getMessage());
117: }
118: }
119: }
|