Clover coverage report - Clover results for XOM 1.2d1
Coverage timestamp: Wed Feb 8 2006 08:31:33 EST
file stats: LOC: 167   Methods: 11
NCLOC: 93   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
XIncludeExceptionTest.java - 88.9% 100% 91.1%
coverage coverage
 1    /* Copyright 2003-2005 Elliotte Rusty Harold
 2   
 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.
 6   
 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.
 11   
 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
 16   
 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/
 20    */
 21   
 22    package nu.xom.tests;
 23   
 24    import nu.xom.xinclude.BadEncodingAttributeException;
 25    import nu.xom.xinclude.BadParseAttributeException;
 26    import nu.xom.xinclude.MisplacedFallbackException;
 27    import nu.xom.xinclude.NoIncludeLocationException;
 28    import nu.xom.xinclude.XIncludeException;
 29   
 30    /**
 31    * <p>
 32    * Unit tests for the <code>XIncludeException</code> class.
 33    * </p>
 34    *
 35    * @author Elliotte Rusty Harold
 36    * @version 1.1b3
 37    *
 38    */
 39    public class XIncludeExceptionTest extends XOMTestCase {
 40   
 41    private XIncludeException ex;
 42    private Exception cause;
 43   
 44   
 45  9 public XIncludeExceptionTest(String name) {
 46  9 super(name);
 47    }
 48   
 49   
 50  9 protected void setUp() {
 51  9 ex = new XIncludeException("message");
 52  9 cause = new Exception();
 53    }
 54   
 55   
 56  1 public void testConstructor() {
 57  1 ex = new XIncludeException("test", "http://ex.com/");
 58  1 assertEquals("test", ex.getMessage());
 59  1 assertEquals("http://ex.com/", ex.getURI());
 60    }
 61   
 62   
 63  1 public void testInitCause() {
 64   
 65  1 assertNull(ex.getCause());
 66  1 ex.initCause(cause);
 67  1 assertEquals(cause, ex.getCause());
 68   
 69  1 try {
 70  1 ex.initCause(null);
 71  0 fail("Reinitialized cause over null");
 72    }
 73    catch (IllegalStateException result) {
 74    // success
 75    }
 76   
 77  1 try {
 78  1 ex.initCause(new Exception());
 79  0 fail("Reinitialized cause over null");
 80    }
 81    catch (IllegalStateException result) {
 82    // success
 83    }
 84   
 85    }
 86   
 87   
 88  1 public void testNullInitCause() {
 89   
 90  1 XIncludeException ex
 91    = new XIncludeException("message", (Exception) null);
 92  1 assertNull(ex.getCause());
 93   
 94  1 try {
 95  1 ex.initCause(new Exception());
 96  0 fail("Reinitialized cause over null");
 97    }
 98    catch (IllegalStateException result) {
 99    // success
 100    }
 101   
 102  1 try {
 103  1 ex.initCause(null);
 104  0 fail("Reinitialized cause over null");
 105    }
 106    catch (IllegalStateException result) {
 107    // success
 108    }
 109   
 110    }
 111   
 112   
 113  1 public void testSelfCause() {
 114   
 115  1 try {
 116  1 ex.initCause(ex);
 117  0 fail("Allowed self-causation");
 118    }
 119    catch (IllegalArgumentException success) {
 120    // success
 121    }
 122   
 123    }
 124   
 125   
 126  1 public void testGetMessage() {
 127  1 Exception ex = new XIncludeException("testing");
 128  1 assertEquals("testing", ex.getMessage());
 129    }
 130   
 131   
 132  1 public void testMisplacedFallbackException() {
 133  1 String message = "message";
 134  1 Exception ex = new MisplacedFallbackException(message);
 135  1 assertEquals(message, ex.getMessage());
 136    }
 137   
 138   
 139  1 public void testBadParseAttributeException() {
 140  1 String message = "message";
 141  1 Exception ex = new BadParseAttributeException(message);
 142  1 assertEquals(message, ex.getMessage());
 143    }
 144   
 145   
 146  1 public void testBadEncodingAttributeException() {
 147  1 String message = "message";
 148  1 Exception ex = new BadEncodingAttributeException(message);
 149  1 assertEquals(message, ex.getMessage());
 150    }
 151   
 152   
 153  1 public void testNoIncludeLocationException() {
 154   
 155  1 String message = "message";
 156  1 XIncludeException ex = new NoIncludeLocationException(message);
 157  1 assertEquals(message, ex.getMessage());
 158  1 assertNull(ex.getCause());
 159   
 160  1 Exception cause = new Exception();
 161  1 ex = new NoIncludeLocationException(message, cause);
 162  1 assertEquals(message, ex.getMessage());
 163  1 assertEquals(cause, ex.getCause());
 164   
 165    }
 166   
 167    }