/*
   Copyright 2008-2009 Christian Vest Hansen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package net.nanopool;

import static org.junit.Assert.*;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import org.junit.Test;

/**
 * 
 * @author cvh
 */
public class InterruptionTest extends NanoPoolTestBase {
  @Test public void
  mustPreserveInterruptionState() throws SQLException {
    Thread.currentThread().interrupt();
    pool = npds();
    Connection con = pool.getConnection();
    con.close();
    List<SQLException> sqles = pool.close();
    for (SQLException sqle : sqles) {
      sqle.printStackTrace();
    }
    assertTrue(sqles.isEmpty());
    assertTrue(Thread.interrupted());
  }
}

@@ -653,16 +653,53 @@
 ssert.*;
+%0Aimport static org.mockito.Mockito.*;
 %0A%0Aimport
@@ -784,22 +784,314 @@
 ort 
-org.junit.Test
+java.util.concurrent.atomic.AtomicReference;%0A%0Aimport javax.sql.ConnectionEvent;%0Aimport javax.sql.ConnectionEventListener;%0Aimport javax.sql.ConnectionPoolDataSource;%0Aimport javax.sql.PooledConnection;%0A%0Aimport org.junit.Test;%0Aimport org.mockito.invocation.InvocationOnMock;%0Aimport org.mockito.stubbing.Answer
 ;%0A%0A/
@@ -1562,10 +1562,1230 @@
 ));%0A  %7D%0A
-%7D
+%0A  @Override%0A  protected ConnectionPoolDataSource buildCpds() throws SQLException %7B%0A    final AtomicReference%3CConnectionEventListener%3E connectionEventListener =%0A      new AtomicReference%3CConnectionEventListener%3E();%0A    ConnectionPoolDataSource source = mock(ConnectionPoolDataSource.class);%0A    final PooledConnection pcon = mock(PooledConnection.class);%0A    Connection con = mock(Connection.class);%0A    %0A    when(source.getPooledConnection()).thenReturn(pcon);%0A    doAnswer(new Answer%3CObject%3E() %7B%0A      public Object answer(InvocationOnMock invocation) throws Throwable %7B%0A        connectionEventListener.set(%0A            (ConnectionEventListener) invocation.getArguments()%5B0%5D);%0A        return null;%0A      %7D%0A    %7D).when(pcon).addConnectionEventListener(%0A        (ConnectionEventListener) anyObject());%0A    doAnswer(new Answer%3CObject%3E() %7B%0A      public Object answer(InvocationOnMock invocation) throws Throwable %7B%0A        ConnectionEventListener cel = connectionEventListener.get();%0A        ConnectionEvent event = new ConnectionEvent(pcon);%0A        cel.connectionClosed(event);%0A        return null;%0A      %7D%0A    %7D).when(con).close();%0A    %0A    when(pcon.getConnection()).thenReturn(con);%0A    %0A    return source;%0A  %7D%0A%7D%0A%0A%0A%0A%0A%0A
 %0A

fix the InterruptionTest that broke when we switched to embedded Derby by default in the tests. Who would have thought that Derby cleared the interruption flag?