1
/* Copyright 2003-2005 Elliotte Rusty Harold
3
This library is free software; you can redistribute it and/or modify
4
it under the terms of version 2.1 of the GNU Lesser General Public
5
License as published by the Free Software Foundation.
7
This library is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU Lesser General Public License for more details.
12
You should have received a copy of the GNU Lesser General Public
13
License along with this library; if not, write to the
14
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
15
Boston, MA 02111-1307 USA
17
You can contact Elliotte Rusty Harold by sending e-mail to
18
elharo@metalab.unc.edu. Please include the word "XOM" in the
19
subject line. The XOM home page is located at http://www.xom.nu/
24
import nu.xom.canonical.CanonicalizationException;
28
* Unit tests for the <code>CanonicalizationException</code> class.
31
* @author Elliotte Rusty Harold
35
public class CanonicalizationExceptionTest extends XOMTestCase {
38
private CanonicalizationException ex;
39
private Exception cause;
42
public CanonicalizationExceptionTest(String name) {
47
protected void setUp() {
48
ex = new CanonicalizationException("message");
49
cause = new Exception();
53
public void testConstructor() {
54
String message = "testing 1-2-3";
55
CanonicalizationException ex = new CanonicalizationException(message);
56
assertEquals(message, ex.getMessage());
60
public void testInitCause() {
62
assertNull(ex.getCause());
64
assertEquals(cause, ex.getCause());
68
fail("Reinitialized cause over null");
70
catch (IllegalStateException success) {
71
assertNotNull(success.getMessage());
75
ex.initCause(new Exception());
76
fail("Reinitialized cause over null");
78
catch (IllegalStateException success) {
79
assertNotNull(success.getMessage());
85
public void testNullInitCause() {
87
CanonicalizationException ex = new CanonicalizationException(null);
89
assertNull(ex.getCause());
92
ex.initCause(new Exception());
93
fail("Reinitialized cause over null");
95
catch (IllegalStateException success) {
96
assertNotNull(success.getMessage());
101
fail("Reinitialized cause over null");
103
catch (IllegalStateException success) {
104
assertNotNull(success.getMessage());
110
public void testSelfCause() {
114
fail("Allowed self-causation");
116
catch (IllegalArgumentException success) {
117
assertNotNull(success.getMessage());
123
public void testGetMessage() {
124
Exception ex = new CanonicalizationException("testing");
125
assertEquals("testing", ex.getMessage());