@@ -0,0 +1,3184 @@
+/*%0A * Copyright 2017, TeamDev Ltd. All rights reserved.%0A *%0A * Redistribution and use in source and/or binary forms, with or without%0A * modification, must retain the above copyright notice and the following%0A * disclaimer.%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR%0A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT%0A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,%0A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT%0A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,%0A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY%0A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT%0A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE%0A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0A%0Apackage org.spine3.server.storage.jdbc.util;%0A%0Aimport org.junit.Test;%0Aimport org.spine3.server.storage.jdbc.DatabaseException;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.SQLException;%0A%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.junit.Assert.fail;%0Aimport static org.mockito.Mockito.doThrow;%0Aimport static org.mockito.Mockito.mock;%0A%0A/**%0A * @author Dmytro Dashenkov.%0A */%0Apublic class ConnectionWrapperShould %7B%0A%0A    @SuppressWarnings(%22ObjectEquality%22)%0A    @Test%0A    public void store_and_retrieve_connection() %7B%0A        final Connection connection = mockConnection();%0A        final ConnectionWrapper wrapper = ConnectionWrapper.wrap(connection);%0A        final Connection stored = wrapper.get();%0A        assertTrue(stored == connection); // Same object%0A    %7D%0A%0A    @Test(expected = DatabaseException.class)%0A    public void throw_DatabaseException_on_SQLException_on_commit() %7B%0A        final Connection connection = mockConnection();%0A        final ConnectionWrapper wrapper = ConnectionWrapper.wrap(connection);%0A        wrapper.commit();%0A    %7D%0A%0A    @Test(expected = DatabaseException.class)%0A    public void throw_DatabaseException_on_SQLException_on_rollback() %7B%0A        final Connection connection = mockConnection();%0A        final ConnectionWrapper wrapper = ConnectionWrapper.wrap(connection);%0A        wrapper.rollback();%0A    %7D%0A%0A    @Test(expected = DatabaseException.class)%0A    public void throw_DatabaseException_on_SQLException_on_close() %7B%0A        final Connection connection = mockConnection();%0A        final ConnectionWrapper wrapper = ConnectionWrapper.wrap(connection);%0A        wrapper.close();%0A    %7D%0A%0A    private static Connection mockConnection() %7B%0A        final Connection connection = mock(Connection.class);%0A        @SuppressWarnings(%22NewExceptionWithoutArguments%22)%0A        final Exception exception = new SQLException();%0A        try %7B%0A            doThrow(exception).when(connection).commit();%0A            doThrow(exception).when(connection).rollback();%0A            doThrow(exception).when(connection).close();%0A        %7D catch (SQLException e) %7B%0A            fail(%22Didn't want to catch that.%22);%0A        %7D%0A        return connection;%0A    %7D%0A%7D%0A

Add ConnectionWrapper tests.