01: /*
02: * Copyright 2003-2004 Michael Franken, Zilverline.
03: *
04: * The contents of this file, or the files included with this file, are subject to
05: * the current version of ZILVERLINE Collaborative Source License for the
06: * Zilverline Search Engine (the "License"); You may not use this file except in
07: * compliance with the License.
08: *
09: * You may obtain a copy of the License at
10: *
11: * http://www.zilverline.org.
12: *
13: * See the License for the rights, obligations and
14: * limitations governing use of the contents of the file.
15: *
16: * The Original and Upgraded Code is the Zilverline Search Engine. The developer of
17: * the Original and Upgraded Code is Michael Franken. Michael Franken owns the
18: * copyrights in the portions it created. All Rights Reserved.
19: *
20: */
21:
22: package org.zilverline.core;
23:
24: import javax.servlet.ServletException;
25:
26: import junit.framework.TestCase;
27:
28: import org.apache.commons.logging.Log;
29: import org.apache.commons.logging.LogFactory;
30:
31: /**
32: * DOCUMENT ME!
33: *
34: * @author michael To change the template for this generated type comment go to Window>Preferences>Java>Code
35: * Generation>Code and Comments
36: */
37: public class TestIndexException extends TestCase {
38: /** logger for Commons logging. */
39: private static Log log = LogFactory
40: .getLog(TestIndexException.class);
41:
42: /**
43: * Creates a new TestCollection object.
44: *
45: * @param arg0 DOCUMENT ME!
46: */
47: public TestIndexException(String arg0) {
48: super (arg0);
49: }
50:
51: /**
52: * This methods increases unit test coverage.
53: */
54: public void testException() {
55: try {
56: throw new IndexException("Error in Index");
57: } catch (IndexException ie) {
58: assertEquals("Error in Index", ie.getMessage());
59: }
60: }
61:
62: /**
63: * This methods tests ServletException and 1.4 Throwable cause hierarchy.
64: */
65: public void testExceptionHierarchy() {
66: try {
67: try {
68: throw new Exception("Error");
69: } catch (Exception e) {
70: try {
71: throw new IndexException("Error in Index", e);
72: } catch (IndexException ie) {
73: throw new ServletException("Error in Servlet", ie);
74: }
75: }
76: } catch (ServletException se) {
77: Throwable rootCause = se.getRootCause();
78: Throwable seCause = se.getCause();
79:
80: assertNotNull(rootCause);
81: assertNull(seCause);
82: assertEquals("Error in Index", rootCause.getMessage());
83:
84: Throwable cause = rootCause.getCause();
85:
86: assertNotNull(cause);
87: assertEquals("Error", cause.getMessage());
88: assertEquals("Error in Servlet", se.getMessage());
89: }
90: }
91: }
|