// // Examine a single method to see if it raises SQLFeatureNotSupportedException. // private void vetMethod( Object candidate, Class iface, Method method, HashSet<String> unsupportedList, HashSet<String> notUnderstoodList) throws Exception { try { method.invoke(candidate, getNullArguments(method.getParameterTypes())); // it's ok for the method to succeed } catch (Throwable e) { if (!(e instanceof InvocationTargetException)) { recordUnexpectedError(candidate, iface, method, notUnderstoodList, e); } else { Throwable cause = e.getCause(); if (cause instanceof SQLFeatureNotSupportedException) { boolean isExcludable = isExcludable(method); if (!isExcludable) { StackTraceElement[] stack = cause.getStackTrace(); int i = 0; while (i < stack.length && !stack[i].getMethodName().equals("notImplemented")) { ++i; } while (i < stack.length && stack[i].getMethodName().equals("notImplemented")) { ++i; } if (i == stack.length) { // cause.printStackTrace(); } unsupportedList.add( candidate.getClass().getName() + ": " + method + "@" + (i == stack.length ? "no source" : cause.getStackTrace()[i])); } else { } } else if (cause instanceof SQLException) { // swallow other SQLExceptions, caused by bogus args } else if (cause instanceof NullPointerException) { // swallow other NPEs, caused by bogus args } else if (cause instanceof ArrayIndexOutOfBoundsException) { // swallow these, caused by bogus args } else { recordUnexpectedError(candidate, iface, method, notUnderstoodList, cause); } } } }
/** * Checks if the invocation of the method throws a SQLExceptio as expected. * * @param LOB the Object that implements the Blob interface * @param method the method that needs to be tested to ensure that it throws the correct exception * @return true If the method throws the SQLException required after the free method has been * called on the LOB object */ boolean checkIfMethodThrowsSQLException(Object LOB, Method method) throws IllegalAccessException, InvocationTargetException { try { method.invoke(LOB, getNullValues(method.getParameterTypes())); } catch (InvocationTargetException ite) { Throwable cause = ite.getCause(); if (cause instanceof SQLException) { return ((SQLException) cause).getSQLState().equals("XJ215"); } throw ite; } return false; }