| 1 |  |  | 
        
| 2 |  |  | 
        
| 3 |  |  | 
        
| 4 |  |  | 
        
| 5 |  |  | 
        
| 6 |  |  | 
        
| 7 |  |  | 
        
| 8 |  |  | 
        
| 9 |  |  | 
        
| 10 |  |  | 
        
| 11 |  |  | 
        
| 12 |  |  | 
        
| 13 |  |  | 
        
| 14 |  |  | 
        
| 15 |  |  | 
        
| 16 |  |  | 
        
| 17 |  |  | 
        
| 18 |  |  | 
        
| 19 |  |  | 
        
| 20 |  |  | 
        
| 21 |  | package org.perfectjpattern.support.test; | 
        
| 22 |  |  | 
        
| 23 |  | import junit.framework.*; | 
        
| 24 |  |  | 
        
| 25 |  |  | 
        
| 26 |  | @link | 
        
| 27 |  | @link | 
        
| 28 |  |  | 
        
| 29 |  | @author | 
        
| 30 |  | @version | 
        
| 31 |  |  | 
        
| 32 |  | public abstract | 
           
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (20) | Complexity: 6 | Complexity Density: 0.33 |  | 
  
| 33 |  | class AbstractTestRuntimeException<E extends RuntimeException> | 
        
| 34 |  | extends TestCase | 
        
| 35 |  | { | 
        
| 36 |  |  | 
        
| 37 |  |  | 
        
| 38 |  |  | 
           
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (1) | Complexity: 1 | Complexity Density: 1 |  | 
  
| 39 | 2 |  public ... | 
        
| 40 |  | AbstractTestRuntimeException(Class<E> aClass) | 
        
| 41 |  | { | 
        
| 42 |  | assert aClass != null : "'aClass' must not be null"; | 
        
| 43 |  |  | 
        
| 44 | 2 | theClass = aClass; | 
        
| 45 |  | } | 
        
| 46 |  |  | 
        
| 47 |  |  | 
           
        |  |  | 
           
           |  | 100% | Uncovered Elements: 0 (17) | Complexity: 5 | Complexity Density: 0.29 | 4
   - |  | 
  
| 48 | 2 |  public void... | 
        
| 49 |  | testException() | 
        
| 50 |  | throws Exception | 
        
| 51 |  | { | 
        
| 52 | 2 | String myClassName = theClass.getSimpleName(); | 
        
| 53 |  |  | 
        
| 54 | 2 | String myCause2 = "Database corrupt"; | 
        
| 55 | 2 | Throwable myCause3 = new RuntimeException("Disconnected"); | 
        
| 56 | 2 | String myCause4a = "Illegal Statement"; | 
        
| 57 | 2 | Throwable myCause4b = new RuntimeException(myCause4a); | 
        
| 58 |  |  | 
        
| 59 | 2 | RuntimeException myException1 = theClass.newInstance(); | 
        
| 60 | 2 | RuntimeException myException2 = theClass.getDeclaredConstructor(String. | 
        
| 61 |  | class).newInstance(myCause2); | 
        
| 62 | 2 | RuntimeException myException3 = theClass.getDeclaredConstructor( | 
        
| 63 |  | Throwable.class).newInstance(myCause3); | 
        
| 64 | 2 | RuntimeException myException4 = theClass.getDeclaredConstructor( | 
        
| 65 |  | String.class, Throwable.class).newInstance(myCause4a, myCause4b); | 
        
| 66 |  |  | 
        
| 67 | 2 | try | 
        
| 68 |  | { | 
        
| 69 |  | throw myException1; | 
        
| 70 |  | } | 
        
| 71 |  |  | 
        
| 72 |  | catch (RuntimeException anException) | 
        
| 73 |  |  | 
        
| 74 |  | { | 
        
| 75 | 2 | assertNull(myClassName + " did not work as expected",  anException. | 
        
| 76 |  | getMessage()); | 
        
| 77 |  | } | 
        
| 78 |  |  | 
        
| 79 | 2 | try | 
        
| 80 |  | { | 
        
| 81 |  | throw myException2; | 
        
| 82 |  | } | 
        
| 83 |  |  | 
        
| 84 |  | catch (RuntimeException anException) | 
        
| 85 |  |  | 
        
| 86 |  | { | 
        
| 87 | 2 | assertEquals(myClassName + " did not work as expected", myCause2, | 
        
| 88 |  | anException.getMessage()); | 
        
| 89 |  | } | 
        
| 90 |  |  | 
        
| 91 | 2 | try | 
        
| 92 |  | { | 
        
| 93 |  | throw myException3; | 
        
| 94 |  | } | 
        
| 95 |  |  | 
        
| 96 |  | catch (RuntimeException anException) | 
        
| 97 |  |  | 
        
| 98 |  | { | 
        
| 99 | 2 | assertEquals(myClassName + " did not work as expected", myCause3, | 
        
| 100 |  | anException.getCause()); | 
        
| 101 |  | } | 
        
| 102 |  |  | 
        
| 103 | 2 | try | 
        
| 104 |  | { | 
        
| 105 |  | throw myException4; | 
        
| 106 |  | } | 
        
| 107 |  |  | 
        
| 108 |  | catch (RuntimeException anException) | 
        
| 109 |  |  | 
        
| 110 |  | { | 
        
| 111 | 2 | assertEquals(myClassName + " did not work as expected", myCause4b, | 
        
| 112 |  | anException.getCause()); | 
        
| 113 |  | } | 
        
| 114 |  | } | 
        
| 115 |  |  | 
        
| 116 |  |  | 
        
| 117 |  |  | 
        
| 118 |  |  | 
        
| 119 |  | private final Class<E> theClass; | 
        
| 120 |  | } |