I am new to using wait and notify. I have trouble in testing my code. Below is my implementation: (NOTE: I have not included all the implementation)
public class PoolImp {
  private Vector<Connection> connections; // For now maximum of 1 connection
  public synchronized Connection getconnection() {
       if(connections.size == 1() ) {
         this.wait();
     }
      return newConnection(); // also add to connections
  }
 public synchronized void removeconnection() {
       connections.size = 0;
       this.notify();
  }
}
Below is my test method: conn_1 gets the first connection. conn_2 goes into wait as only maximum of 1 connection is allowed.
I want to test this in such a way that when I call removeconnection, conn_2 gets notified and gets the released connection.
Testing : @Test
 public void testGetConnections() throws SQLException
{  
  PoolImpl cp = new PoolImpl();
  Connection conn_1 = null;
  Connection conn_2 = null;
  conn_1 = cp.getConnection();
  conn_2 = cp.getConnection();
  cp.removeConnection(conn_1);}
}   
 
     
     
     
    