### Question:
OAuth2TokenDAO extends AbstractSearcherDAO implements IOAuth2TokenDAO { @Override public OAuth2AccessToken readAccessToken(final String accessToken) { Connection conn = null; OAuth2AccessToken token = null; try { conn = this.getConnection(); token = this.getAccessToken(accessToken, conn); } catch (Exception t) { logger.error("Error while loading token {}", accessToken, t); throw new RuntimeException("Error while loading token " + accessToken, t); } finally { this.closeConnection(conn); } return token; }  @Override List<OAuth2AccessToken> findTokensByClientIdAndUserName(String clientId, String username); @Override List<OAuth2AccessToken> findTokensByUserName(String username); @Override List<OAuth2AccessToken> findTokensByClientId(String clientId); @Override void storeAccessToken(OAuth2AccessToken accessToken, OAuth2Authentication authentication); @Override OAuth2AccessToken readAccessToken(final String accessToken); @Override void removeAccessToken(final String accessToken); @Override void removeAccessTokenUsingRefreshToken(String refreshToken); @Override void deleteExpiredToken(int expirationTime); @Override OAuth2RefreshToken readRefreshToken(String tokenValue); @Override OAuth2Authentication readAuthenticationForRefreshToken(OAuth2RefreshToken refreshToken);  }### Answer:
@Test(expected = RuntimeException.class) public void failReadAccessToken() throws Exception { try { when(this.stat.executeQuery()).thenReturn(res); Mockito.when(res.next()).thenReturn(true).thenReturn(false); when(res.getTimestamp(Mockito.anyString())).thenThrow(SQLException.class); OAuth2AccessToken token = this.tokenDAO.readAccessToken("token"); Assert.fail(); } catch (RuntimeException e) { Mockito.verify(stat, Mockito.times(1)).setString(Mockito.anyInt(), Mockito.anyString()); Mockito.verify(res, Mockito.times(4)).getString(Mockito.anyString()); Mockito.verify(res, Mockito.times(1)).getTimestamp(Mockito.anyString()); Mockito.verify(res, Mockito.times(1)).close(); Mockito.verify(stat, Mockito.times(1)).close(); Mockito.verify(conn, Mockito.times(1)).close(); throw e; } }