Code example for InvocationTargetException

Methods: printStackTrace

0
    } 
     
    /** 
     * @tests java.lang.reflect.InvocationTargetException#getCause() 
     */ 
    @TestTargetNew( 
        level = TestLevel.COMPLETE, 
        notes = "", 
        method = "getCause", 
        args = {} 
    ) 
    public void test_getCause() { 
        // java.lang.reflect.InvocationTargetException.getCause() 
        try { 
            Method mth = TestMethod.class.getDeclaredMethod(
                    "invokeExceptionTest", new Class[0]);
            Object[] args = {Object.class};
            Object ret = mth.invoke(new TestMethod(), new Object[0]);
        } catch (InvocationTargetException e) {
            // Correct behaviour 
            assertTrue("Returned incorrect cause",