UnknownTypeHandler extends BaseTypeHandler<Object> { @Override public Object getNullableResult(ResultSet rs, String columnName) throws SQLException { TypeHandler<?> handler = resolveTypeHandler(rs, columnName); return handler.getResult(rs, columnName); } UnknownTypeHandler(TypeHandlerRegistry typeHandlerRegistry); @Override void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType); @Override Object getNullableResult(ResultSet rs, String columnName); @Override Object getNullableResult(ResultSet rs, int columnIndex); @Override Object getNullableResult(CallableStatement cs, int columnIndex);  }
@Test public void getResultWithResultSetAndColumnNameThrowsException() throws SQLException { doThrow(new SQLException("invalid column")).when((UnknownTypeHandler)TYPE_HANDLER).getNullableResult(rs, "foo"); try { TYPE_HANDLER.getResult(rs, "foo"); Assert.fail("Should have thrown a ResultMapException"); } catch (Exception e) { Assert.assertTrue("Expected ResultMapException", e instanceof ResultMapException); Assert.assertTrue("column name is not in exception", e.getMessage().contains("column 'foo'")); } }
@Test public void getResultWithResultSetAndColumnIndexThrowsException() throws SQLException { doThrow(new SQLException("invalid column")).when((UnknownTypeHandler)TYPE_HANDLER).getNullableResult(rs, 1); try { TYPE_HANDLER.getResult(rs, 1); Assert.fail("Should have thrown a ResultMapException"); } catch (Exception e) { Assert.assertTrue("Expected ResultMapException", e instanceof ResultMapException); Assert.assertTrue("column index is not in exception", e.getMessage().contains("column #1")); } }
@Test public void getResultWithCallableStatementAndColumnIndexThrowsException() throws SQLException { doThrow(new SQLException("invalid column")).when((UnknownTypeHandler)TYPE_HANDLER).getNullableResult(cs, 1); try { TYPE_HANDLER.getResult(cs, 1); Assert.fail("Should have thrown a ResultMapException"); } catch (Exception e) { Assert.assertTrue("Expected ResultMapException", e instanceof ResultMapException); Assert.assertTrue("column index is not in exception", e.getMessage().contains("column #1")); } }