Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
29   95   7   4.14
0   54   0.24   7
7     1  
1    
 
  QedeqExceptionTest       Line # 26 29 7 94.4% 0.9444444
 
  (4)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.se.common;
17   
18    import org.qedeq.base.test.QedeqTestCase;
19    import org.qedeq.base.utility.EqualsUtility;
20   
21    /**
22    * Test class.
23    *
24    * @author Michael Meyling
25    */
 
26    public class QedeqExceptionTest extends QedeqTestCase {
27   
28    private QedeqException ex1;
29    private QedeqException ex2;
30    private QedeqException ex4;
31   
 
32  0 toggle public QedeqExceptionTest(){
33  0 super();
34    }
35   
 
36  4 toggle public QedeqExceptionTest(final String name){
37  4 super(name);
38    }
39   
 
40  4 toggle public void setUp() throws Exception {
41  4 super.setUp();
42  4 this.ex1 = new QedeqException(107, "I am a bug!",
43    new RuntimeException("I am the reason.")) {};
44  4 this.ex2 = new QedeqException(-107, "I am a bug!",
45    new RuntimeException("I am the reason.")) {};
46  4 this.ex4 = new QedeqException(107, "I am a bug!",
47    new RuntimeException("I am the next reason.")) {};
48    }
49   
50    /**
51    * Test constructor.
52    */
 
53  1 toggle public void testConstructor() {
54  1 assertEquals(107, ex1.getErrorCode());
55  1 assertEquals("I am a bug!", ex1.getMessage());
56  1 assertEquals(-107, ex2.getErrorCode());
57  1 assertEquals("I am a bug!", ex2.getMessage());
58  1 assertEquals("I am the reason.", ex2.getCause().getMessage());
59  1 assertEquals(107, ex4.getErrorCode());
60  1 assertEquals("I am a bug!", ex4.getMessage());
61    }
62   
63    /**
64    * Test hash code generation.
65    */
 
66  1 toggle public void testHashCode() {
67  1 assertTrue(ex1.hashCode() != ex2.hashCode());
68  1 assertTrue(ex1.hashCode() != ex4.hashCode());
69  1 assertTrue(ex2.hashCode() != ex4.hashCode());
70    }
71   
 
72  1 toggle public void testEqualsObject() {
73  1 assertFalse(EqualsUtility.equals(ex1, ex2));
74  1 assertFalse(EqualsUtility.equals(ex2, ex4));
75  1 assertFalse(EqualsUtility.equals(ex1, ex4));
76  1 assertFalse(ex1.equals(null));
77  1 assertFalse(ex2.equals(null));
78  1 assertFalse(ex4.equals(null));
79    }
80   
81   
82    /*
83    * Test toString.
84    */
 
85  1 toggle public void testToString() {
86  1 assertEquals(107, ex1.getErrorCode());
87  1 assertEquals("I am a bug!", ex1.getMessage());
88  1 assertEquals(-107, ex2.getErrorCode());
89  1 assertEquals("I am a bug!", ex2.getMessage());
90  1 assertEquals("I am the reason.", ex2.getCause().getMessage());
91  1 assertEquals(107, ex4.getErrorCode());
92  1 assertEquals("I am a bug!", ex4.getMessage());
93    }
94   
95    }