### Question:
ThriftTransportKey { public SaslConnectionParams getSaslParams() { return saslParams; } @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(expected = RuntimeException.class) public void testSslAndSaslErrors() { ClientContext clientCtx = createMock(ClientContext.class); SslConnectionParams sslParams = createMock(SslConnectionParams.class); SaslConnectionParams saslParams = createMock(SaslConnectionParams.class); expect(clientCtx.getClientSslParams()).andReturn(sslParams).anyTimes(); expect(clientCtx.getSaslParams()).andReturn(saslParams).anyTimes(); replay(clientCtx); try { new ThriftTransportKey(HostAndPort.fromParts("localhost", 9999), 120 * 1000, clientCtx); } finally { verify(clientCtx); } }
@Test public void testSimpleEquivalence() { ClientContext clientCtx = createMock(ClientContext.class); expect(clientCtx.getClientSslParams()).andReturn(null).anyTimes(); expect(clientCtx.getSaslParams()).andReturn(null).anyTimes(); replay(clientCtx); ThriftTransportKey ttk = new ThriftTransportKey(HostAndPort.fromParts("localhost", 9999), 120 * 1000, clientCtx); assertEquals("Normal ThriftTransportKey doesn't equal itself", ttk, ttk); }