@Test public void testTimeout() { h.getConfig(SqlStatements.class).setQueryTimeout(2); assertThatCode(h.createQuery("select pg_sleep(1)").mapTo(String.class)::findOnly) .doesNotThrowAnyException(); assertThatThrownBy(h.createQuery("select pg_sleep(3)").mapTo(String.class)::findOnly) .isInstanceOf(UnableToExecuteStatementException.class) .hasMessageContaining("canceling statement due to user request"); } }