Skip to content

Instantly share code, notes, and snippets.

@oshai
Created January 17, 2019 07:39
Show Gist options
  • Save oshai/1a15f70854d45d27eb95bea680f90f68 to your computer and use it in GitHub Desktop.
Save oshai/1a15f70854d45d27eb95bea680f90f68 to your computer and use it in GitHub Desktop.
@Test
fun `"Simple query with 1 nanosec timeout"`() {
withConfigurablePool(shortTimeoutConfiguration()) { pool ->
{
val connection = pool.take().get(10, TimeUnit.SECONDS)
assertThat(connection.isTimeout()).isEqualTo(false)
assertThat(connection.isConnected()).isEqualTo(true)
val queryResultFuture = connection.sendQuery("select sleep(1)")
verifyException(TimeoutException::class.java) {
queryResultFuture.get(10, TimeUnit.SECONDS)
}
assertThat(connection.isTimeout()).isEqualTo(true)
pool.giveBack(connection).get(10, TimeUnit.SECONDS)
assertThat(pool.availables().size).isEqualTo(0) // connection removed from pool)
// we do not know when the connection will be closed.
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment