/** * Execute the {@link Sniffer.Executable#execute()} method, record the SQL queries * and return the {@link Spy} object with stats * @param executable code to test * @return statistics on executed queries * @throws RuntimeException if underlying code under test throws an Exception * @since 2.0 */ @Deprecated public static Spy execute(Executable executable) { return Sniffy.execute(executable); }
/** * Execute the {@link Sniffer.Executable#execute()} method, record the SQL queries * and return the {@link Spy} object with stats * @param executable code to test * @return statistics on executed queries * @throws RuntimeException if underlying code under test throws an Exception * @since 2.0 */ @Deprecated public static Spy execute(Executable executable) { return Sniffy.execute(executable); }
@Test public void testFunctionalApi() throws SQLException { // tag::testFunctionalApi[] final Connection connection = DriverManager.getConnection("sniffy:jdbc:h2:mem:", "sa", "sa"); // <1> Sniffy.execute( () -> connection.createStatement().execute("SELECT 1 FROM DUAL") ).verify(SqlQueries.atMostOneQuery()); // <2> // end::testFunctionalApi[] }