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