001: /**
002: * $Id: FileStatCommunityNodeTest.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.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: import java.io.UnsupportedEncodingException;
025:
026: public class FileStatCommunityNodeTest extends FileStatCommunityTest {
027: public FileStatCommunityNodeTest(String testName) {
028: super (testName);
029: }
030:
031: protected void setUp() throws java.lang.Exception {
032: super .setUp();
033: Debug.log("FileStatCommunityNodeTest", "setUp", "called");
034: }
035:
036: protected void tearDown() throws java.lang.Exception {
037: super .tearDown();
038: Debug.log("FileStatCommunityNodeTest", "tearDown", "called");
039: }
040:
041: public static Test suite() {
042: TestSuite suite = new TestSuite(FileStatCommunityNodeTest.class);
043: return suite;
044: }
045:
046: public void testGetCommunityPrincipal() {
047: Debug.log("FileStatCommunityNodeTest",
048: "testGetCommunityPrincipal", "called");
049:
050: try {
051: CMCPrincipal cp = orgNode.getCMCPrincipal();
052: assertNotNull(cp);
053: assertEquals(orgCp, cp);
054: } catch (CMCException ce) {
055: Debug.log("FileStatCommunityNodeTest",
056: "testGetCommunityPrincipal", ce);
057: fail(ce.getMessage());
058: }
059: }
060:
061: public void testCreate() {
062: Debug.log("FileStatCommunityNodeTest", "testCreate", "called");
063:
064: try {
065: orgNode.create();
066: fail("create did not fail");
067: } catch (UnsupportedOperationException ce) {
068: // expected
069: } catch (CMCException ce) {
070: Debug.log("FileStatCommunityNodeTest", "testCreate", ce);
071: fail(ce.getMessage());
072: }
073: }
074:
075: public void testSupportsCreate() {
076: try {
077: Debug.log("FileStatCommunityNodeTest",
078: "testSupportsCreate", "called");
079: assertFalse(orgNode.supportsCreate());
080: } catch (CMCException ce) {
081: Debug.log("FileStatCommunityNodeTest",
082: "testSupportsCreate", ce);
083: fail(ce.getMessage());
084: }
085: }
086:
087: public void testExists() {
088: Debug.log("FileStatCommunityNodeTest", "testExists", "called");
089:
090: try {
091: assertTrue(orgNode.exists());
092: } catch (CMCException ce) {
093: Debug.log("FileStatCommunityNodeTest", "testExists", ce);
094: fail(ce.getMessage());
095: }
096: }
097:
098: public void testAddUsers() {
099: Debug
100: .log("FileStatCommunityNodeTest", "testAddUsers",
101: "called");
102:
103: try {
104: orgNode.addUsers(Collections.EMPTY_SET,
105: CMCRolePrincipal.MEMBER_ROLE);
106: fail("addUsers did not fail");
107: } catch (UnsupportedOperationException ce) {
108: // expected
109: } catch (CMCException ce) {
110: Debug.log("FileStatCommunityNodeTest", "testAddUsers", ce);
111: fail(ce.getMessage());
112: }
113: }
114:
115: public void testAddRole() {
116: Debug.log("FileStatCommunityNodeTest", "testAddRole", "called");
117:
118: try {
119: orgNode.addRole(CMCRolePrincipal.DISABLED_ROLE);
120: fail("addRole did not fail");
121: } catch (UnsupportedOperationException ce) {
122: // expected
123: } catch (CMCException ce) {
124: Debug.log("FileStatCommunityNodeTest", "testAddRole", ce);
125: fail(ce.getMessage());
126: }
127: }
128:
129: public void testGetUsers() {
130: Debug
131: .log("FileStatCommunityNodeTest", "testGetUsers",
132: "called");
133:
134: try {
135: Set allUsers = orgNode.getUsers();
136: assertEquals(3, allUsers.size());
137: } catch (CMCException ce) {
138: Debug.log("FileStatCommunityNodeTest", "testGetUsers", ce);
139: fail(ce.getMessage());
140: }
141: }
142:
143: public void testGetRoles() {
144: Debug
145: .log("FileStatCommunityNodeTest", "testGetRoles",
146: "called");
147:
148: try {
149: Set roles = orgNode.getRoles();
150: fail("getRoles did not fail");
151: } catch (UnsupportedOperationException ce) {
152: // expected
153: } catch (CMCException ce) {
154: Debug.log("FileStatCommunityNodeTest", "testGetRoles", ce);
155: fail(ce.getMessage());
156: }
157: }
158:
159: public void testSupportsAddUsers() {
160: try {
161: Debug.log("FileStatCommunityNodeTest",
162: "testSupportsAddUsers", "called");
163: assertFalse(orgNode.supportsAddUsers());
164: } catch (CMCException ce) {
165: Debug.log("FileStatCommunityNodeTest",
166: "testSupportsAddUsers", ce);
167: fail(ce.getMessage());
168: }
169: }
170:
171: public void testSupportsAddRole() {
172: try {
173: Debug.log("FileStatCommunityNodeTest",
174: "testSupportsAddRole", "called");
175: assertFalse(orgNode.supportsAddRole());
176: } catch (CMCException ce) {
177: Debug.log("FileStatCommunityNodeTest",
178: "testSupportsAddRole", ce);
179: fail(ce.getMessage());
180: }
181: }
182:
183: public void testRemoveUsers() {
184: Debug.log("FileStatCommunityNodeTest", "testRemoveUsers",
185: "called");
186:
187: try {
188: orgNode.removeUsers(Collections.EMPTY_SET,
189: Collections.EMPTY_SET);
190: fail("removeUsers did not fail");
191: } catch (UnsupportedOperationException ce) {
192: // expected
193: } catch (CMCException ce) {
194: Debug.log("FileStatCommunityNodeTest", "testRemoveUsers",
195: ce);
196: fail(ce.getMessage());
197: }
198:
199: }
200:
201: public void testRemoveUserPatterns() {
202: Debug.log("FileStatCommunityNodeTest",
203: "testRemoveUserPatterns", "called");
204:
205: try {
206: orgNode.removeUsers(Collections.EMPTY_SET,
207: Collections.EMPTY_SET);
208: fail("removeUsers did not fail");
209: } catch (UnsupportedOperationException ce) {
210: // expected
211: } catch (CMCException ce) {
212: Debug.log("FileStatCommunityNodeTest",
213: "testRemoveUserPatterns", ce);
214: fail(ce.getMessage());
215: }
216:
217: }
218:
219: public void testSupportsRemoveUsers() {
220: try {
221: Debug.log("FileStatCommunityNodeTest",
222: "testSupportsRemoveUsers", "called");
223: assertFalse(orgNode.supportsRemoveUsers());
224: } catch (CMCException ce) {
225: Debug.log("FileStatCommunityNodeTest",
226: "testSupportsRemoveUsers", ce);
227: fail(ce.getMessage());
228: }
229: }
230:
231: public void testSupportsRemoveRole() {
232: try {
233: Debug.log("FileStatCommunityNodeTest",
234: "testSupportsRemoveRole", "called");
235: assertFalse(orgNode.supportsRemoveRole());
236: } catch (CMCException ce) {
237: Debug.log("FileStatCommunityNodeTest",
238: "testSupportsRemoveRole", ce);
239: fail(ce.getMessage());
240: }
241: }
242:
243: public void testSupportsRole() {
244: try {
245: Debug.log("FileStatCommunityNodeTest", "testSupportsRole",
246: "called");
247: assertFalse(orgNode
248: .supportsRole(CMCRolePrincipal.VISITOR_ROLE));
249: assertTrue(orgNode
250: .supportsRole(CMCRolePrincipal.MEMBER_ROLE));
251: assertFalse(orgNode
252: .supportsRole(CMCRolePrincipal.OWNER_ROLE));
253: } catch (CMCException ce) {
254: Debug.log("FileStatCommunityNodeTest", "testSupportsRole",
255: ce);
256: fail(ce.getMessage());
257: }
258: }
259:
260: public void testRemove() {
261: Debug.log("FileStatCommunityNodeTest", "testRemove", "called");
262:
263: try {
264: orgNode.remove();
265: fail("remove did not fail");
266: } catch (UnsupportedOperationException ce) {
267: // expected
268: } catch (CMCException ce) {
269: Debug.log("FileStatCommunityNodeTest", "testRemove", ce);
270: fail(ce.getMessage());
271: }
272: }
273:
274: public void testSupportsRemove() {
275: try {
276: Debug.log("FileStatCommunityNodeTest",
277: "testSupportsRemove", "called");
278: assertFalse(orgNode.supportsRemove());
279: } catch (CMCException ce) {
280: Debug.log("FileStatCommunityNodeTest",
281: "testSupportsRemove", ce);
282: fail(ce.getMessage());
283: }
284: }
285:
286: public void testSetDPDocuments() {
287: Debug.log("FileStatCommunityNodeTest", "testSetDPDocuments",
288: "called");
289:
290: try {
291: ConfigTable lastReadTimes = new ConfigTable();
292: ConfigTable dpDocs = new ConfigTable();
293:
294: dpDocs.put(orgMemberCk, ORG_MEMBER_DP);
295:
296: orgNode.setDPDocuments(dpDocs);
297: } catch (CMCException ce) {
298: Debug.log("CommunityUserTest", "testSetDPDocuments", ce);
299: fail(ce.getMessage());
300: }
301: }
302:
303: public void testGetDPDocuments() {
304: Debug.log("FileStatCommunityNodeTest", "testGetDPDocuments",
305: "called");
306:
307: try {
308: ConfigTable dpDocuments = orgNode.getDPDocuments();
309: assertEquals(1, dpDocuments.size());
310:
311: try {
312: byte[] dpm = (byte[]) dpDocuments.get(orgMemberCk);
313: assertNotNull(dpm);
314: String dpmString = new String(dpm, "UTF-8");
315: assertEquals(ORG_MEMBER_DP, dpmString);
316: } catch (UnsupportedEncodingException uec) {
317: fail("unsupported encoding");
318: }
319: } catch (CMCException ce) {
320: Debug.log("FileStatCommunityNodeTest", "testExists", ce);
321: fail(ce.getMessage());
322: }
323: }
324:
325: public void testGetDescription() {
326: Debug.log("FileStatCommunityNodeTest", "testGetDescription",
327: "called");
328:
329: try {
330: orgNode.getDescription();
331: fail("getDescription did not fail");
332: } catch (UnsupportedOperationException ce) {
333: // expected
334: } catch (CMCException ce) {
335: Debug.log("FileStatCommunityNodeTest",
336: "testGetDescription", ce);
337: fail(ce.getMessage());
338: }
339: }
340:
341: public void testSetDescription() {
342: Debug.log("FileStatCommunityNodeTest", "testSetDescription",
343: "called");
344:
345: try {
346: orgNode.setDescription("new test description");
347: fail("setDescription did not fail");
348: } catch (UnsupportedOperationException ce) {
349: // expected
350: } catch (CMCException ce) {
351: Debug.log("FileStatCommunityNodeTest",
352: "testSetDescription", ce);
353: fail(ce.getMessage());
354: }
355: }
356:
357: public void testSupportsDescription() {
358: Debug.log("FileStatCommunityNodeTest",
359: "testSupportsDescription", "called");
360: try {
361: assertFalse(orgNode.supportsDescription());
362: } catch (CMCException ce) {
363: Debug.log("FileStatCommunityNodeTest",
364: "testSupportsDescription", ce);
365: fail(ce.getMessage());
366: }
367: }
368:
369: public void testGetCategory() {
370: Debug.log("FileStatCommunityNodeTest", "testGetCategory",
371: "called");
372:
373: try {
374: orgNode.getCategory();
375: fail("getCategory did not fail");
376: } catch (UnsupportedOperationException ce) {
377: // expected
378: } catch (CMCException ce) {
379: Debug.log("FileStatCommunityNodeTest", "testGetCategory",
380: ce);
381: fail(ce.getMessage());
382: }
383: }
384:
385: public void testSetCategory() {
386: Debug.log("FileStatCommunityNodeTest", "testSetCategory",
387: "called");
388:
389: try {
390: orgNode.setCategory("new test category");
391: fail("setCategory did not fail");
392: } catch (UnsupportedOperationException ce) {
393: // expected
394: } catch (CMCException ce) {
395: Debug.log("FileStatCommunityNodeTest", "testSetCategory",
396: ce);
397: fail(ce.getMessage());
398: }
399: }
400:
401: public void testSupportsCategory() {
402: Debug.log("FileStatCommunityNodeTest", "testSupportsCategory",
403: "called");
404: try {
405: assertFalse(orgNode.supportsCategory());
406: } catch (CMCException ce) {
407: Debug.log("FileStatCommunityNodeTest",
408: "testSupportsCategory", ce);
409: fail(ce.getMessage());
410: }
411: }
412:
413: public void testGetCommunityCreationTime() {
414: Debug.log("FileStatCommunityNodeTest",
415: "testGetCommunityCreationTime", "called");
416:
417: try {
418: orgNode.getCommunityCreationTime();
419: fail("getCommunityCreationTime did not fail");
420: } catch (UnsupportedOperationException ce) {
421: // expected
422: } catch (CMCException ce) {
423: Debug.log("FileStatCommunityNodeTest",
424: "testCommunityCreationTime", ce);
425: fail(ce.getMessage());
426: }
427: }
428:
429: public void testSupportsCommunityCreationTime() {
430: Debug.log("FileStatCommunityNodeTest",
431: "testSupportsCommunityCreationTime", "called");
432: try {
433: assertFalse(orgNode.supportsCommunityCreationTime());
434: } catch (CMCException ce) {
435: Debug.log("FileStatCommunityNodeTest",
436: "testSupportsCommunityCreationTime", ce);
437: fail(ce.getMessage());
438: }
439: }
440:
441: public void testIsMembershipRestricted() {
442: Debug.log("FileStatCommunityNodeTest",
443: "testIsMembershipRestricted", "called");
444:
445: try {
446: orgNode.isMembershipRestricted();
447: fail("isMembershipRestricted did not fail");
448: } catch (UnsupportedOperationException ce) {
449: // expected
450: } catch (CMCException ce) {
451: Debug.log("FileStatCommunityNodeTest",
452: "testIsMembershipRestricted", ce);
453: fail(ce.getMessage());
454: }
455: }
456:
457: public void testSetMembershipRestricted() {
458: Debug.log("FileStatCommunityNodeTest",
459: "testSetMembershipRestricted", "called");
460:
461: try {
462: orgNode.setMembershipRestricted(false);
463: fail("setMembershipRestricted did not fail");
464: } catch (UnsupportedOperationException ce) {
465: // expected
466: } catch (CMCException ce) {
467: Debug.log("FileStatCommunityNodeTest",
468: "testSetMembershipRestricted", ce);
469: fail(ce.getMessage());
470: }
471: }
472:
473: public void testSupportsMembershipRestriction() {
474: Debug.log("FileStatCommunityNodeTest",
475: "testSupportsMembershipRestriction", "called");
476: try {
477: assertFalse(orgNode.supportsMembershipRestriction());
478: } catch (CMCException ce) {
479: Debug.log("FileStatCommunityNodeTest",
480: "testSupportsMembershipRestriction", ce);
481: fail(ce.getMessage());
482: }
483: }
484:
485: public void testIsSecure() {
486: Debug
487: .log("FileStatCommunityNodeTest", "testIsSecure",
488: "called");
489:
490: try {
491: orgNode.isSecure();
492: fail("isSecure did not fail");
493: } catch (UnsupportedOperationException ce) {
494: // expected
495: } catch (CMCException ce) {
496: Debug.log("FileStatCommunityNodeTest", "testIsSecure", ce);
497: fail(ce.getMessage());
498: }
499: }
500:
501: public void testSetSecure() {
502: Debug.log("FileStatCommunityNodeTest", "testSetSecure",
503: "called");
504:
505: try {
506: orgNode.setSecure(false);
507: fail("setSecure did not fail");
508: } catch (UnsupportedOperationException ce) {
509: // expected
510: } catch (CMCException ce) {
511: Debug.log("FileStatCommunityNodeTest", "testSetSecure", ce);
512: fail(ce.getMessage());
513: }
514: }
515:
516: public void testSupportsSecuring() {
517: Debug.log("FileStatCommunityNodeTest", "testSupportsSecuring",
518: "called");
519: try {
520: assertFalse(orgNode.supportsSecuring());
521: } catch (CMCException ce) {
522: Debug.log("FileStatCommunityNodeTest",
523: "testSupportsSecuring", ce);
524: fail(ce.getMessage());
525: }
526: }
527:
528: public void testIsListed() {
529: Debug
530: .log("FileStatCommunityNodeTest", "testIsListed",
531: "called");
532:
533: try {
534: orgNode.isListed();
535: fail("isListed did not fail");
536: } catch (UnsupportedOperationException ce) {
537: // expected
538: } catch (CMCException ce) {
539: Debug.log("FileStatCommunityNodeTest", "testIsListed", ce);
540: fail(ce.getMessage());
541: }
542: }
543:
544: public void testSetListed() {
545: Debug.log("FileStatCommunityNodeTest", "testSetListed",
546: "called");
547:
548: try {
549: orgNode.setListed(false);
550: fail("testSetListed did not fail");
551: } catch (UnsupportedOperationException ce) {
552: // expected
553: } catch (CMCException ce) {
554: Debug.log("FileStatCommunityNodeTest", "testSetListed", ce);
555: fail(ce.getMessage());
556: }
557: }
558:
559: public void testSupportsListing() {
560: Debug.log("FileStatCommunityNodeTest", "testSupportsListing",
561: "called");
562: try {
563: assertFalse(orgNode.supportsListing());
564: } catch (CMCException ce) {
565: Debug.log("FileStatCommunityNodeTest",
566: "testSupportsListing", ce);
567: fail(ce.getMessage());
568: }
569: }
570:
571: public void testSupportsRoleCreationTime() {
572: Debug.log("FileStatCommunityNodeTest",
573: "testSupportsRoleCreationTime", "called");
574: try {
575: assertFalse(orgNode.supportsRoleCreationTime());
576: } catch (CMCException ce) {
577: Debug.log("FileStatCommunityNodeTest",
578: "testSupportsRoleCreationTime", ce);
579: fail(ce.getMessage());
580: }
581: }
582:
583: }
|