@Override public boolean isValid(int timeout) throws SQLException { checkOpen(); return super.isValid(timeout); }
@Override public boolean isValid(int timeout) throws SQLException { throwIfClosed(); try { return super.isValid(timeout); } catch (UnsupportedOperationException e) { throw new SQLFeatureNotSupportedException(e.getMessage(), e); } }
@Override public boolean isValid(int timeout) throws SQLException { checkOpen(); return super.isValid(timeout); }
@Test public void testIsValid() throws SQLException { AvaticaConnection connection = Mockito.mock(AvaticaConnection.class, Mockito.CALLS_REAL_METHODS); try { connection.isValid(-1); Assert.fail("Connection isValid should throw SQLException on negative timeout"); } catch (SQLException expected) { Assert.assertEquals("timeout is less than 0", expected.getMessage()); } Mockito.when(connection.isClosed()).thenReturn(false); Assert.assertTrue(connection.isValid(0)); Mockito.when(connection.isClosed()).thenReturn(true); Assert.assertFalse(connection.isValid(0)); }
@Test public void testIsValid() throws SQLException { AvaticaConnection connection = Mockito.mock(AvaticaConnection.class, Mockito.CALLS_REAL_METHODS); try { connection.isValid(-1); Assert.fail("Connection isValid should throw SQLException on negative timeout"); } catch (SQLException expected) { Assert.assertEquals("timeout is less than 0", expected.getMessage()); } Mockito.when(connection.isClosed()).thenReturn(false); Assert.assertTrue(connection.isValid(0)); Mockito.when(connection.isClosed()).thenReturn(true); Assert.assertFalse(connection.isValid(0)); }