001: /**
002: * $Id: AMCommunityNodeTest.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.Collections;
016: import java.util.HashSet;
017: import junit.framework.*;
018: import java.util.Set;
019:
020: import com.sun.portal.community.mc.*;
021: import com.sun.portal.community.mc.ConfigTable.ConfigKey;
022: import com.sun.portal.community.mc.impl.Debug;
023:
024: public class AMCommunityNodeTest extends AMCommunityTest {
025: public AMCommunityNodeTest(String testName) {
026: super (testName);
027: }
028:
029: protected void setUp() throws java.lang.Exception {
030: super .setUp();
031: Debug.log("AMCommunityNodeTest", "setUp", "called");
032: }
033:
034: protected void tearDown() throws java.lang.Exception {
035: super .tearDown();
036: Debug.log("AMCommunityNodeTest", "tearDown", "called");
037: }
038:
039: public static Test suite() {
040: TestSuite suite = new TestSuite(AMCommunityNodeTest.class);
041: return suite;
042: }
043:
044: public void testGetCommunityPrincipal() {
045: Debug.log("AMCommunityNodeTest", "testGetCommunityPrincipal",
046: "called");
047:
048: try {
049: CMCPrincipal cp = orgNode.getCMCPrincipal();
050: assertNotNull(cp);
051: assertEquals(orgCp, cp);
052: } catch (CMCException ce) {
053: Debug.log("AMCommunityNodeTest",
054: "testGetCommunityPrincipal", ce);
055: fail(ce.getMessage());
056: }
057: }
058:
059: public void testCreate() {
060: Debug.log("AMCommunityNodeTest", "testCreate", "called");
061:
062: try {
063: orgNode.create();
064: fail("create did not fail");
065: } catch (UnsupportedOperationException ce) {
066: // expected
067: } catch (CMCException ce) {
068: Debug.log("AMCommunityNodeTest", "testCreate", ce);
069: fail(ce.getMessage());
070: }
071: }
072:
073: public void testSupportsCreate() {
074: Debug
075: .log("AMCommunityNodeTest", "testSupportsCreate",
076: "called");
077: try {
078: assertFalse(orgNode.supportsCreate());
079: } catch (CMCException ce) {
080: Debug.log("AMCommunityNodeTest", "testSupportsCreate", ce);
081: fail(ce.getMessage());
082: }
083: }
084:
085: public void testExists() {
086: Debug.log("AMCommunityNodeTest", "testExists", "called");
087:
088: try {
089: assertTrue(orgNode.exists());
090: } catch (CMCException ce) {
091: Debug.log("AMCommunityNodeTest", "testExists", ce);
092: fail(ce.getMessage());
093: }
094: }
095:
096: public void testAddUsers() {
097: Debug.log("AMCommunityNodeTest", "testAddUsers", "called");
098:
099: try {
100: orgNode.addUsers(Collections.EMPTY_SET,
101: CMCRolePrincipal.MEMBER_ROLE);
102: fail("addUsers did not fail");
103: } catch (UnsupportedOperationException ce) {
104: // expected
105: } catch (CMCException ce) {
106: Debug.log("AMCommunityNodeTest", "testAddUsers", ce);
107: fail(ce.getMessage());
108: }
109: }
110:
111: public void testGetUsers() {
112: Debug.log("AMCommunityNodeTest", "testGetUsers", "called");
113:
114: try {
115: // nothing much
116: // just make sure the call goes through
117: Set allUsers = orgNode.getUsers();
118: assertNotNull(allUsers);
119: } catch (CMCException ce) {
120: Debug.log("AMCommunityNodeTest", "testGetUsers", ce);
121: fail(ce.getMessage());
122: }
123: }
124:
125: public void testSupportsAddUsers() {
126: Debug.log("AMCommunityNodeTest", "testSupportsAddUsers",
127: "called");
128: try {
129: assertFalse(orgNode.supportsAddUsers());
130: } catch (CMCException ce) {
131: Debug
132: .log("AMCommunityNodeTest", "testSupportsAddUsers",
133: ce);
134: fail(ce.getMessage());
135: }
136: }
137:
138: public void testRemoveUsers() {
139: Debug.log("AMCommunityNodeTest", "testRemoveUsers", "called");
140:
141: try {
142: orgNode.removeUsers(Collections.EMPTY_SET,
143: Collections.EMPTY_SET);
144: fail("removeUsers did not fail");
145: } catch (UnsupportedOperationException ce) {
146: // expected
147: } catch (CMCException ce) {
148: Debug.log("AMCommunityNodeTest", "testRemoveUsers", ce);
149: fail(ce.getMessage());
150: }
151:
152: }
153:
154: public void testSupportsRemoveUsers() {
155: Debug.log("AMCommunityNodeTest", "testSupportsRemoveUsers",
156: "called");
157: try {
158: assertFalse(orgNode.supportsRemoveUsers());
159: } catch (CMCException ce) {
160: Debug.log("AMCommunityNodeTest", "testSupportsRemoveUsers",
161: ce);
162: fail(ce.getMessage());
163: }
164: }
165:
166: public void testSupportsRole() {
167: Debug.log("AMCommunityNodeTest", "testSupportsRole", "called");
168: try {
169: assertFalse(orgNode
170: .supportsRole(CMCRolePrincipal.VISITOR_ROLE));
171: assertTrue(orgNode
172: .supportsRole(CMCRolePrincipal.MEMBER_ROLE));
173: assertFalse(orgNode
174: .supportsRole(CMCRolePrincipal.OWNER_ROLE));
175: assertFalse(orgNode
176: .supportsRole(CMCRolePrincipal.BANNED_ROLE));
177: assertFalse(orgNode
178: .supportsRole(CMCRolePrincipal.INVITED_ROLE));
179: assertFalse(orgNode
180: .supportsRole(CMCRolePrincipal.REJECTED_ROLE));
181: assertFalse(orgNode
182: .supportsRole(CMCRolePrincipal.PENDING_ROLE));
183: } catch (CMCException ce) {
184: Debug.log("AMCommunityNodeTest", "testSupportsRole", ce);
185: fail(ce.getMessage());
186: }
187: }
188:
189: public void testRemove() {
190: Debug.log("AMCommunityNodeTest", "testRemove", "called");
191:
192: try {
193: orgNode.remove();
194: fail("remove did not fail");
195: } catch (UnsupportedOperationException ce) {
196: // expected
197: } catch (CMCException ce) {
198: Debug.log("AMCommunityNodeTest", "testRemove", ce);
199: fail(ce.getMessage());
200: }
201: }
202:
203: public void testSupportsRemove() {
204: Debug
205: .log("AMCommunityNodeTest", "testSupportsRemove",
206: "called");
207: try {
208: assertFalse(orgNode.supportsRemove());
209: } catch (CMCException ce) {
210: Debug.log("AMCommunityNodeTest", "testSupportsRemove", ce);
211: fail(ce.getMessage());
212: }
213: }
214:
215: public void testSetDPDocuments() {
216: Debug
217: .log("AMCommunityNodeTest", "testSetDPDocuments",
218: "called");
219:
220: try {
221: orgNode.setDPDocuments(new ConfigTable());
222: fail("setDPDocuments did not fail");
223: } catch (UnsupportedOperationException ce) {
224: // expected
225: } catch (CMCException ce) {
226: Debug.log("AMCommunityNodeTest", "testSetDPDocuments", ce);
227: fail(ce.getMessage());
228: }
229: }
230:
231: public void testGetDPDocuments() {
232: Debug
233: .log("AMCommunityNodeTest", "testGetDPDocuments",
234: "called");
235:
236: try {
237: // nothing much
238: // just make sure the call goes through okay
239: ConfigTable dpDocuments = orgNode.getDPDocuments();
240: assertNotNull(dpDocuments);
241: } catch (CMCException ce) {
242: Debug.log("AMCommunityNodeTest", "testExists", ce);
243: fail(ce.getMessage());
244: }
245: }
246:
247: public void testGetDescription() {
248: Debug
249: .log("AMCommunityNodeTest", "testGetDescription",
250: "called");
251:
252: try {
253: orgNode.getDescription();
254: fail("getDescription did not fail");
255: } catch (UnsupportedOperationException ce) {
256: // expected
257: } catch (CMCException ce) {
258: Debug.log("AMCommunityNodeTest", "testGetDescription", ce);
259: fail(ce.getMessage());
260: }
261: }
262:
263: public void testSetDescription() {
264: Debug
265: .log("AMCommunityNodeTest", "testSetDescription",
266: "called");
267:
268: try {
269: orgNode.setDescription("new test description");
270: fail("setDescription did not fail");
271: } catch (UnsupportedOperationException ce) {
272: // expected
273: } catch (CMCException ce) {
274: Debug.log("AMCommunityNodeTest", "testSetDescription", ce);
275: fail(ce.getMessage());
276: }
277: }
278:
279: public void testSupportsDescription() {
280: Debug.log("AMCommunityNodeTest", "testSupportsDescription",
281: "called");
282: try {
283: assertFalse(orgNode.supportsDescription());
284: } catch (CMCException ce) {
285: Debug.log("AMCommunityNodeTest", "testSupportsDescription",
286: ce);
287: fail(ce.getMessage());
288: }
289: }
290:
291: public void testGetCategory() {
292: Debug.log("AMCommunityNodeTest", "testGetCategory", "called");
293:
294: try {
295: orgNode.getCategory();
296: fail("getCategory did not fail");
297: } catch (UnsupportedOperationException ce) {
298: // expected
299: } catch (CMCException ce) {
300: Debug.log("AMCommunityNodeTest", "testGetCategory", ce);
301: fail(ce.getMessage());
302: }
303: }
304:
305: public void testSetCategory() {
306: Debug.log("AMCommunityNodeTest", "testSetCategory", "called");
307:
308: try {
309: orgNode.setCategory("new test category");
310: fail("setCategory did not fail");
311: } catch (UnsupportedOperationException ce) {
312: // expected
313: } catch (CMCException ce) {
314: Debug.log("AMCommunityNodeTest", "testSetCategory", ce);
315: fail(ce.getMessage());
316: }
317: }
318:
319: public void testSupportsCategory() {
320: Debug.log("AMCommunityNodeTest", "testSupportsCategory",
321: "called");
322: try {
323: assertFalse(orgNode.supportsCategory());
324: } catch (CMCException ce) {
325: Debug
326: .log("AMCommunityNodeTest", "testSupportsCategory",
327: ce);
328: fail(ce.getMessage());
329: }
330: }
331:
332: public void testGetCommunityCreationTime() {
333: Debug.log("AMCommunityNodeTest",
334: "testGetCommunityCreationTime", "called");
335:
336: try {
337: orgNode.getCommunityCreationTime();
338: fail("getCommunityCreationTime did not fail");
339: } catch (UnsupportedOperationException ce) {
340: // expected
341: } catch (CMCException ce) {
342: Debug.log("AMCommunityNodeTest",
343: "testCommunityCreationTime", ce);
344: fail(ce.getMessage());
345: }
346: }
347:
348: public void testSupportsCommunityCreationTime() {
349: Debug.log("AMCommunityNodeTest",
350: "testSupportsCommunityCreationTime", "called");
351: try {
352: assertFalse(orgNode.supportsCommunityCreationTime());
353: } catch (CMCException ce) {
354: Debug.log("AMCommunityNodeTest",
355: "testSupportsCommunityCreationTime", ce);
356: fail(ce.getMessage());
357: }
358: }
359:
360: public void testIsMembershipRestricted() {
361: Debug.log("AMCommunityNodeTest", "testIsMembershipRestricted",
362: "called");
363:
364: try {
365: orgNode.isMembershipRestricted();
366: fail("isMembershipRestricted did not fail");
367: } catch (UnsupportedOperationException ce) {
368: // expected
369: } catch (CMCException ce) {
370: Debug.log("AMCommunityNodeTest",
371: "testIsMembershipRestricted", ce);
372: fail(ce.getMessage());
373: }
374: }
375:
376: public void testSetMembershipRestricted() {
377: Debug.log("AMCommunityNodeTest", "testSetMembershipRestricted",
378: "called");
379:
380: try {
381: orgNode.setMembershipRestricted(false);
382: fail("setMembershipRestricted did not fail");
383: } catch (UnsupportedOperationException ce) {
384: // expected
385: } catch (CMCException ce) {
386: Debug.log("AMCommunityNodeTest",
387: "testSetMembershipRestricted", ce);
388: fail(ce.getMessage());
389: }
390: }
391:
392: public void testSupportsMembershipRestriction() {
393: Debug.log("AMCommunityNodeTest",
394: "testSupportsMembershipRestriction", "called");
395: try {
396: assertFalse(orgNode.supportsMembershipRestriction());
397: } catch (CMCException ce) {
398: Debug.log("AMCommunityNodeTest",
399: "testSupportsMembershipRestriction", ce);
400: fail(ce.getMessage());
401: }
402: }
403:
404: public void testIsSecure() {
405: Debug.log("AMCommunityNodeTest", "testIsSecure", "called");
406:
407: try {
408: orgNode.isSecure();
409: fail("isSecure did not fail");
410: } catch (UnsupportedOperationException ce) {
411: // expected
412: } catch (CMCException ce) {
413: Debug.log("AMCommunityNodeTest", "testIsSecure", ce);
414: fail(ce.getMessage());
415: }
416: }
417:
418: public void testSetSecure() {
419: Debug.log("AMCommunityNodeTest", "testSetSecure", "called");
420:
421: try {
422: orgNode.setSecure(false);
423: fail("setSecure did not fail");
424: } catch (UnsupportedOperationException ce) {
425: // expected
426: } catch (CMCException ce) {
427: Debug.log("AMCommunityNodeTest", "testSetSecure", ce);
428: fail(ce.getMessage());
429: }
430: }
431:
432: public void testSupportsSecuring() {
433: Debug.log("AMCommunityNodeTest", "testSupportsSecuring",
434: "called");
435: try {
436: assertFalse(orgNode.supportsSecuring());
437: } catch (CMCException ce) {
438: Debug
439: .log("AMCommunityNodeTest", "testSupportsSecuring",
440: ce);
441: fail(ce.getMessage());
442: }
443: }
444:
445: public void testIsListed() {
446: Debug.log("AMCommunityNodeTest", "testIsListed", "called");
447:
448: try {
449: orgNode.isListed();
450: fail("isListed did not fail");
451: } catch (UnsupportedOperationException ce) {
452: // expected
453: } catch (CMCException ce) {
454: Debug.log("AMCommunityNodeTest", "testIsListed", ce);
455: fail(ce.getMessage());
456: }
457: }
458:
459: public void testSetListed() {
460: Debug.log("AMCommunityNodeTest", "testSetListed", "called");
461:
462: try {
463: orgNode.setListed(false);
464: fail("testSetListed did not fail");
465: } catch (UnsupportedOperationException ce) {
466: // expected
467: } catch (CMCException ce) {
468: Debug.log("AMCommunityNodeTest", "testSetListed", ce);
469: fail(ce.getMessage());
470: }
471: }
472:
473: public void testSupportsListing() {
474: Debug.log("AMCommunityNodeTest", "testSupportsListing",
475: "called");
476: try {
477: assertFalse(orgNode.supportsListing());
478: } catch (CMCException ce) {
479: Debug.log("AMCommunityNodeTest", "testSupportsListing", ce);
480: fail(ce.getMessage());
481: }
482: }
483:
484: public void testSupportsRoleCreationTime() {
485: Debug.log("AMCommunityNodeTest",
486: "testSupportsRoleCreationTime", "called");
487: try {
488: assertFalse(orgNode.supportsRoleCreationTime());
489: } catch (CMCException ce) {
490: Debug.log("AMCommunityNodeTest",
491: "testSupportsRoleCreationTime", ce);
492: fail(ce.getMessage());
493: }
494: }
495:
496: }
|