Clover coverage report - Clover results for XOM 1.2d1
Coverage timestamp: Wed Feb 8 2006 08:31:33 EST
file stats: LOC: 183   Methods: 13
NCLOC: 99   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ParsingExceptionTest.java - 90.2% 100% 92.2%
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   
 26    /**
 27    * <p>
 28    * Unit tests for the <code>ParsingException</code> class.
 29    * </p>
 30    *
 31    * @author Elliotte Rusty Harold
 32    * @version 1.1b2
 33    *
 34    */
 35    public class ParsingExceptionTest extends XOMTestCase {
 36   
 37   
 38    private ParsingException ex;
 39    private Exception cause;
 40    private String message = "testing 1-2-3";
 41   
 42   
 43  11 public ParsingExceptionTest(String name) {
 44  11 super(name);
 45    }
 46   
 47   
 48  11 protected void setUp() {
 49  11 ex = new ParsingException("message");
 50  11 cause = new Exception();
 51    }
 52   
 53   
 54  1 public void testConstructor() {
 55  1 ParsingException ex = new ParsingException(message, cause);
 56  1 assertEquals(message, ex.getMessage());
 57  1 assertEquals(cause, ex.getCause());
 58    }
 59   
 60   
 61  1 public void testFourArgumentConstructor() {
 62   
 63  1 ParsingException ex = new ParsingException(message, 100000, 400000, cause);
 64  1 assertEquals(message, ex.getMessage());
 65  1 assertEquals(cause, ex.getCause());
 66  1 assertEquals(100000, ex.getLineNumber());
 67  1 assertEquals(400000, ex.getColumnNumber());
 68   
 69    }
 70   
 71   
 72  1 public void testLineAndColumnNumbers() {
 73  1 ParsingException ex = new ParsingException(message, 10, 20);
 74  1 assertEquals(message, ex.getMessage());
 75  1 assertNull(ex.getCause());
 76  1 assertEquals(10, ex.getLineNumber());
 77  1 assertEquals(20, ex.getColumnNumber());
 78    }
 79   
 80   
 81  1 public void testLineAndColumnNumbersInToString() {
 82  1 ParsingException ex = new ParsingException(message, -1, -1);
 83  1 String result = ex.toString();
 84  1 assertEquals(-1, result.indexOf("-1"));
 85    }
 86   
 87   
 88  1 public void testToString() {
 89  1 ParsingException ex = new ParsingException(message, 10, 20);
 90  1 assertTrue(ex.toString().endsWith(" at line 10, column 20"));
 91    }
 92   
 93   
 94  1 public void testInitCause() {
 95   
 96  1 assertNull(ex.getCause());
 97  1 ex.initCause(cause);
 98  1 assertEquals(cause, ex.getCause());
 99   
 100  1 try {
 101  1 ex.initCause(null);
 102  0 fail("Reinitialized cause over null");
 103    }
 104    catch (IllegalStateException result) {
 105    // success
 106    }
 107   
 108  1 try {
 109  1 ex.initCause(new Exception());
 110  0 fail("Reinitialized cause over null");
 111    }
 112    catch (IllegalStateException result) {
 113    // success
 114    }
 115   
 116    }
 117   
 118   
 119  1 public void testNullInitCause() {
 120   
 121  1 ParsingException ex = new ParsingException(null, null);
 122  1 assertNull(ex.getCause());
 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 ParsingException("testing");
 158  1 assertEquals("testing", ex.getMessage());
 159    }
 160   
 161   
 162  1 public void testGetURI() {
 163   
 164  1 ParsingException ex = new ParsingException("testing", "http://www.example.org/", 32, 24);
 165  1 assertEquals("http://www.example.org/", ex.getURI());
 166   
 167  1 Exception cause = new Exception("test");
 168  1 ex = new ParsingException("testing", "http://www.example.org/", 32, 24, cause);
 169  1 assertEquals("http://www.example.org/", ex.getURI());
 170  1 assertEquals(cause, ex.getCause());
 171   
 172    }
 173   
 174   
 175  1 public void testURIInToString() {
 176   
 177  1 ParsingException ex = new ParsingException("testing", "http://www.example.org/", 32, 24);
 178  1 assertTrue(ex.toString().indexOf("http://www.example.org/") > 1);
 179   
 180    }
 181   
 182   
 183    }