JdbcPooledConnection extends JdbcPooledConnectionImpl { @Override public boolean equals(Object o) { if (o == null) { return false; } if (o == this) { return true; } if (o instanceof JdbcPooledConnection) { JdbcPooledConnection pooledConnection = (JdbcPooledConnection) o; return new EqualsBuilder().append(pooledConnection.getConnectUrl(), this.getConnectUrl()) .append(pooledConnection.getDriverImp(), this.getDriverImp()) .append(pooledConnection.getMinimumPoolSize(), this.getMinimumPoolSize()) .append(pooledConnection.getMaximumPoolSize(), this.getMaximumPoolSize()) .append(pooledConnection.getAcquireIncrement(), this.getAcquireIncrement()) .append(pooledConnection.getPoolFactory(), this.getPoolFactory()).isEquals(); } return false; } JdbcPooledConnection(); @Override boolean equals(Object o); @Override int hashCode(); Integer getMinimumPoolSize(); void setMinimumPoolSize(Integer minimumPoolSize); int minPoolSize(); Integer getMaximumPoolSize(); void setMaximumPoolSize(Integer maximumPoolSize); int maxPoolSize(); Integer getAcquireIncrement(); void setAcquireIncrement(Integer acquireIncrement); TimeInterval getConnectionAcquireWait(); void setConnectionAcquireWait(TimeInterval connectionAcquireWait); TimeInterval getIdleConnectionTestPeriod(); void setIdleConnectionTestPeriod(TimeInterval idleConnectionTestPeriod); TimeInterval getMaxIdleTime(); void setMaxIdleTime(TimeInterval t); int currentBusyConnectionCount(); int currentConnectionCount(); int currentIdleConnectionCount(); JdbcPoolFactory getPoolFactory(); void setPoolFactory(JdbcPoolFactory f); static final int DEFAULT_MINIMUM_POOL_SIZE; static final int DEFAULT_MAXIMUM_POOL_SIZE; static final int DEFAULT_ACQUIRE_INCREMENT; }
@Test public void testEquals() throws Exception { JdbcPooledConnectionImpl con = createConnection(); String url = "jdbc:derby:memory:" + GUID.safeUUID() + ";create=true"; con.setConnectUrl(url); assertTrue(con.equals(con)); assertFalse(con.equals(null)); assertFalse(con.equals(new Object())); JdbcPooledConnectionImpl con2 = createConnection(); con2.setConnectUrl(url); assertTrue(con.equals(con2)); }