コード例 #1
0
 public void testCheckoutExpiredAvailableConnection() {
   long timeout = pool.getConnectionIdleTime();
   pool.setConnectionIdleTime(0);
   Connection conn = pool.checkout();
   pool.checkin(conn);
   int initCount = pool.connections;
   pool.checkout();
   assertEquals(initCount, pool.connections);
   assertEquals(pool.getNumberAvailableConnections(), 0);
   pool.setConnectionIdleTime(timeout);
 }
コード例 #2
0
  public void testMultipleConnectionPools() {
    // check the number of available connections in the pool
    assertEquals(0, pool.getNumberAvailableConnections());

    // checkout a default db connection
    Connection conn = pool.checkout();
    pool.checkin(conn);
    assertEquals(1, pool.getNumberAvailableConnections());

    // checkout a tigerprawn db connection
    ConnectionPool tp = ConnectionPool.getInstance(OTHER_APP_NAME);
    try {
      assertNotSame(pool, tp);
      assertEquals(0, tp.getNumberAvailableConnections());
      conn = tp.checkout();
      tp.checkin(conn);
      assertEquals(1, pool.getNumberAvailableConnections());
      assertEquals(1, tp.getNumberAvailableConnections());
    } finally {
      if (tp != null) tp.stopPool();
    }
  }