01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal;
07:
08: import junit.framework.TestCase;
09:
10: /**
11: * Testcase for PortalException. The PortalException implementation of
12: * initCause() catches the Throwable implementation's thrown exceptions in the
13: * case of illegal argument (null argument) or illegal state (cause already
14: * init'ed). Therefore PortalException.initCause() should never throw anything
15: * and should always return a reference to the PortalException.
16: *
17: * @author andrew.petro@yale.edu
18: * @version $Revision: 34870 $ $Date: 2004-10-30 12:55:42 -0700 (Sat, 30 Oct 2004) $
19: */
20: public class PortalExceptionTest extends TestCase {
21:
22: /*
23: * @see TestCase#setUp()
24: */
25: protected void setUp() throws Exception {
26: super .setUp();
27: }
28:
29: /*
30: * @see TestCase#tearDown()
31: */
32: protected void tearDown() throws Exception {
33: super .tearDown();
34: }
35:
36: /**
37: * Test that calling the deprecated legacy method
38: * setRecordedException(null) does not throw any exceptions.
39: */
40: public void testSetNullRecordedException() {
41: PortalException pe = new PortalException("Dummy message");
42: pe.setRecordedException(null);
43: }
44:
45: /**
46: * Test that calling setRecordedException multiple times does not
47: * throw any exceptions.
48: */
49: public void testSetRecordedExceptionMulitply() {
50: PortalException pe = new PortalException("Dummy message");
51: Exception causeOne = new Exception();
52: pe.setRecordedException(causeOne);
53: Exception causeTwo = new Exception();
54: pe.setRecordedException(causeTwo);
55: }
56:
57: /**
58: * Test that setRecordedException populates the Throwable.getCause()
59: * of a PortalException.
60: */
61: public void testSetRecordedException() {
62: PortalException pe = new PortalException("Dummy message");
63: Exception cause = new Exception();
64: pe.setRecordedException(cause);
65: assertEquals(cause, pe.getCause());
66: }
67:
68: }
|