### Question:
ThriftTransportKey { @Override public int hashCode() { if (hash == -1) hash = Objects.hash(server, timeout, sslParams, saslParams); return hash; } @VisibleForTesting  ThriftTransportKey(HostAndPort server, long timeout, ClientContext context);   ThriftTransportKey(HostAndPort server, long timeout, SslConnectionParams sslParams,
      SaslConnectionParams saslParams); boolean isSsl(); boolean isSasl(); @Override boolean equals(Object o); final void precomputeHashCode(); @Override int hashCode(); @Override String toString(); SslConnectionParams getSslParams(); SaslConnectionParams getSaslParams();  }### Answer:
@Test public void testConnectionCaching() throws IOException, InterruptedException { UserGroupInformation user1 = UserGroupInformation.createUserForTesting("user1", new String[0]); final KerberosToken token = EasyMock.createMock(KerberosToken.class); SaslConnectionParams saslParams1 = user1.doAs((PrivilegedExceptionAction<SaslConnectionParams>) () -> createSaslParams(token)); SaslConnectionParams saslParams2 = user1.doAs((PrivilegedExceptionAction<SaslConnectionParams>) () -> createSaslParams(token)); ThriftTransportKey ttk1 = new ThriftTransportKey(HostAndPort.fromParts("localhost", 9997), 1L, null, saslParams1), ttk2 = new ThriftTransportKey(HostAndPort.fromParts("localhost", 9997), 1L, null, saslParams2); assertEquals(ttk1, ttk2); assertEquals(ttk1.hashCode(), ttk2.hashCode()); }
@Test public void testSaslPrincipalIsSignificant() throws IOException, InterruptedException { UserGroupInformation user1 = UserGroupInformation.createUserForTesting("user1", new String[0]); final KerberosToken token = EasyMock.createMock(KerberosToken.class); SaslConnectionParams saslParams1 = user1.doAs((PrivilegedExceptionAction<SaslConnectionParams>) () -> createSaslParams(token)); UserGroupInformation user2 = UserGroupInformation.createUserForTesting("user2", new String[0]); SaslConnectionParams saslParams2 = user2.doAs((PrivilegedExceptionAction<SaslConnectionParams>) () -> createSaslParams(token)); ThriftTransportKey ttk1 = new ThriftTransportKey(HostAndPort.fromParts("localhost", 9997), 1L, null, saslParams1), ttk2 = new ThriftTransportKey(HostAndPort.fromParts("localhost", 9997), 1L, null, saslParams2); assertNotEquals(ttk1, ttk2); assertNotEquals(ttk1.hashCode(), ttk2.hashCode()); }