@Test public void testPoolDescriptorHashCodeAndEquals() { poolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", connConfig, poolConfig, "foo"); Properties sameConnConfig = (Properties) connConfig.clone(); Properties samePoolConfig = (Properties) poolConfig.clone(); PoolDescriptor samePoolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", sameConnConfig, samePoolConfig, "foo"); assertEquals(poolDescriptor.hashCode(), samePoolDescriptor.hashCode()); assertEquals(poolDescriptor, samePoolDescriptor); PoolDescriptor diffPoolDescriptor = new PoolDescriptor("diff-server", "test-jdbcUrl", sameConnConfig, samePoolConfig, "foo"); assertNotEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertNotEquals(poolDescriptor, diffPoolDescriptor); diffPoolDescriptor = new PoolDescriptor("test-server", "diff-jdbcUrl", sameConnConfig, samePoolConfig, "foo"); assertNotEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertNotEquals(poolDescriptor, diffPoolDescriptor); Properties diffConnConfig = (Properties) connConfig.clone(); diffConnConfig.setProperty("user", "foo"); diffPoolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", diffConnConfig, samePoolConfig, "foo"); assertNotEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertNotEquals(poolDescriptor, diffPoolDescriptor); diffConnConfig = (Properties) connConfig.clone(); diffConnConfig.setProperty("password", "bar"); diffPoolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", diffConnConfig, samePoolConfig, "foo"); assertNotEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertNotEquals(poolDescriptor, diffPoolDescriptor); diffConnConfig = (Properties) connConfig.clone(); diffConnConfig.setProperty("foo", "bar"); diffPoolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", diffConnConfig, samePoolConfig, "foo"); assertNotEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertNotEquals(poolDescriptor, diffPoolDescriptor); Properties diffPoolConfig = (Properties) poolConfig.clone(); diffPoolConfig.setProperty("abc", "xyz"); diffPoolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", sameConnConfig, diffPoolConfig, "foo"); assertNotEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertNotEquals(poolDescriptor, diffPoolDescriptor); diffPoolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", sameConnConfig, samePoolConfig, "bar"); assertNotEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertNotEquals(poolDescriptor, diffPoolDescriptor); diffPoolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", sameConnConfig, samePoolConfig, null); assertNotEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertNotEquals(poolDescriptor, diffPoolDescriptor); poolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", connConfig, poolConfig, null); diffPoolDescriptor = new PoolDescriptor("test-server", "test-jdbcUrl", sameConnConfig, samePoolConfig, null); assertEquals(poolDescriptor.hashCode(), diffPoolDescriptor.hashCode()); assertEquals(poolDescriptor, diffPoolDescriptor); }
@Override public int hashCode() { return Objects.hash(server, jdbcUrl, user, password, connectionConfig, poolConfig, qualifier); }
PoolDescriptor { @Override public int hashCode() { return Objects.hash(server, jdbcUrl, user, password, connectionConfig, poolConfig, qualifier); } }
PoolDescriptor { @Override public int hashCode() { return Objects.hash(server, jdbcUrl, user, password, connectionConfig, poolConfig, qualifier); } PoolDescriptor(String server, String jdbcUrl, Properties connectionConfig, Properties poolConfig, String qualifier); }
PoolDescriptor { @Override public int hashCode() { return Objects.hash(server, jdbcUrl, user, password, connectionConfig, poolConfig, qualifier); } PoolDescriptor(String server, String jdbcUrl, Properties connectionConfig, Properties poolConfig, String qualifier); String getServer(); String getJdbcUrl(); String getUser(); String getPassword(); Properties getConnectionConfig(); Properties getPoolConfig(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
PoolDescriptor { @Override public int hashCode() { return Objects.hash(server, jdbcUrl, user, password, connectionConfig, poolConfig, qualifier); } PoolDescriptor(String server, String jdbcUrl, Properties connectionConfig, Properties poolConfig, String qualifier); String getServer(); String getJdbcUrl(); String getUser(); String getPassword(); Properties getConnectionConfig(); Properties getPoolConfig(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }