1 package org.hanseltest; 2 3 7 public class CoverException { 8 9 14 public int coverHandler(int e) { 15 try { 16 return 5 / e; 17 } catch (ArithmeticException ae) { 18 return -1; 19 } 20 } 21 22 28 public int coverFinally(int e, boolean cover) { 29 int result = 0; 30 31 if (cover) { 32 try { 33 result = 5 / e; 34 } finally { 35 result += 1; 36 } 37 } 38 39 return result; 40 } 41 42 49 public int coverComplex(Exception e) { 50 int result = 0; 51 52 try { 53 if (e != null) { 54 throw e; 55 } 56 57 result += 1; 58 } catch (RuntimeException re) { 59 result += 2; 60 } catch (Exception exc) { 61 result += 4; 62 } finally { 63 result += 8; 64 } 65 66 return result; 67 } 68 69 } 70 | Popular Tags |