@@ -0,0 +1,1354 @@
+package com.github.bedrin.jdbc.sniffer;%0A%0Aimport org.junit.Ignore;%0Aimport org.junit.Test;%0A%0Aimport java.lang.ref.WeakReference;%0Aimport java.sql.Connection;%0Aimport java.sql.DriverManager;%0Aimport java.sql.PreparedStatement;%0A%0Aimport static org.junit.Assert.*;%0A%0Apublic class SnifferListenersTest extends BaseTest %7B%0A%0A    @Test%0A    public void testSpyRemovedOnClose() throws Exception %7B%0A        Spy spy = Sniffer.spy();%0A        spy.close();%0A%0A        for (WeakReference%3CSpy%3E spyReference : Sniffer.registeredSpies()) %7B%0A            if (spyReference.get() == spy) fail(%22Spy was not removed from Sniffer observers%22);%0A        %7D%0A%0A    %7D%0A%0A    @Test%0A    @Ignore(%22H2 doesn't seem to support batch queries against DUAL table%22)%0A    public void testBatchIsLogged() throws Exception %7B%0A        try %7B try (Spy spy = Sniffer.expectNever();%0A             Connection connection = DriverManager.getConnection(%22sniffer:jdbc:h2:~/test%22, %22sa%22, %22sa%22);%0A             PreparedStatement preparedStatement = connection.prepareStatement(%22SELECT 1 FROM DUAL WHERE 1 = ?%22)) %7B%0A            preparedStatement.setLong(1, 1);%0A            preparedStatement.addBatch();%0A            preparedStatement.setLong(1, 2);%0A            preparedStatement.addBatch();%0A            preparedStatement.executeBatch();%0A        %7D %7D catch (WrongNumberOfQueriesError e) %7B%0A            assertNotNull(e);%0A        %7D%0A%0A    %7D%0A%0A%7D

Test that spy is removed from sniffer when closed