1 15 package org.apache.hivemind.util; 16 17 import org.apache.hivemind.ApplicationRuntimeException; 18 import org.apache.hivemind.test.HiveMindTestCase; 19 20 27 public class TestConstructorUtils extends HiveMindTestCase 28 { 29 public static class Troublemaker 30 { 31 public Troublemaker(ApplicationRuntimeException ex) 32 { 33 throw ex; 34 } 35 } 36 37 public void testInvocationTargetException() 38 { 39 Throwable inner = new ApplicationRuntimeException("Inner exception."); 40 41 try 42 { 43 ConstructorUtils.invokeConstructor(Troublemaker.class, new Object [] 44 { inner }); 45 46 unreachable(); 47 } 48 catch (ApplicationRuntimeException ex) 49 { 50 String message = UtilMessages.invokeFailed( 51 Troublemaker.class.getConstructors()[0], 52 inner); 53 54 assertEquals(message, ex.getMessage()); 55 assertSame(inner, ex.getCause()); 56 } 57 } 58 } | Popular Tags |