1 28 29 package com.idaremedia.antx.apis; 30 31 import java.lang.reflect.Constructor ; 32 import java.lang.reflect.Method ; 33 34 import org.apache.tools.ant.BuildException; 35 import org.apache.tools.ant.Location; 36 37 49 50 public class BuildAssertionException extends BuildException 51 { 52 55 public BuildAssertionException() 56 { 57 super("Assertion Failed"); 58 initJUnitLink(); 59 } 60 61 62 66 public BuildAssertionException(String msg) 67 { 68 super(msg); 69 initJUnitLink(); 70 } 71 72 73 79 public BuildAssertionException(String msg, Location location) 80 { 81 super(msg,location); 82 initJUnitLink(); 83 } 84 85 86 92 public BuildAssertionException(String msg, Throwable cause) 93 { 94 super(msg,cause); 95 initJUnitLink(); 96 } 97 98 99 107 public BuildAssertionException(String msg, Throwable cause, 108 Location location) 109 { 110 super(msg,cause,location); 111 initJUnitLink(); 112 } 113 114 115 120 public BuildAssertionException(Throwable cause) 121 { 122 super(cause); 123 initJUnitLink(); 124 } 125 126 127 134 public BuildAssertionException(Throwable cause, Location location) 135 { 136 super(cause,location); 137 initJUnitLink(); 138 } 139 140 141 142 private static final Class [] AFE_SIG0= new Class []{String .class}; 143 private static final Class [] AFE_SIG1= new Class []{Throwable .class}; 144 145 146 151 private void initJUnitLink() 152 { 153 try { 154 Class c = Class.forName("junit.framework.AssertionFailedError"); 157 Constructor ctor = c.getConstructor(AFE_SIG0); 158 m_linkJUnit = (Throwable )ctor.newInstance(new Object []{toString()}); 159 Method m= c.getMethod("initCause",AFE_SIG1); 160 m.invoke(m_linkJUnit, new Object []{this}); 161 } catch(Exception anyX) {} 162 } 163 164 165 166 173 public final Throwable getJUnitLink() 174 { 175 return m_linkJUnit; 176 } 177 178 179 private Throwable m_linkJUnit; 180 } 181 182 183 184 | Popular Tags |