ActivityProxyHelper { protected static Class<?> getDefinedException(Method method, Throwable t) { Class<?> ret=null; for (int i=0; ret == null && i < method.getExceptionTypes().length; i++) { if (method.getExceptionTypes()[i].isAssignableFrom(t.getClass())) { ret = method.getExceptionTypes()[i]; } } return (ret); } private  ActivityProxyHelper(); static ActivityProxyHelper setActivityCollector(ActivityCollector collector); @SuppressWarnings("unchecked") static T createClientProxy(String intfName, Object caller, T callee); @SuppressWarnings("unchecked") static T createClientProxy(final Class<T> intf, final Object caller, final T callee); static Object createServiceProxy(final String intfName, final Object callee); static Object createServiceProxy(final Class<?> intf, final Object callee);  }
@Test public void testHandlesException() { try { java.lang.reflect.Method method=TestClass.class.getMethod("testMethod"); if (ActivityProxyHelper.getDefinedException(method, new TestParentException()) != TestParentException.class) { fail("Method should handle parent exception"); } if (ActivityProxyHelper.getDefinedException(method, new TestChildException()) != TestParentException.class) { fail("Method should handle child exception"); } if (ActivityProxyHelper.getDefinedException(method, new IllegalArgumentException()) != null) { fail("Method should NOT handle illegal argument exception"); } } catch (Exception e) { fail("Failed to check if method handles exception"); } }