@Test public void testDestroy() { TProtocol prot = Mockito.mock(TProtocol.class); when(prot.getTransport()).thenReturn(Mockito.mock(TTransport.class)); when(client.getInputProtocol()).thenReturn(prot); ThriftConnection<HelloClient> conn = new ThriftConnection<>(pool, host); conn.destroy(); verify(pool).remove(conn); }
@Test public void testToString() { ThriftConnection<HelloClient> conn = new ThriftConnection<>(pool, host); assertEquals("localhost:8080", conn.toString()); }
@Test public void testValidateWithException() { ThriftConnection<HelloClient> conn = new ThriftConnection<>(pool, host); when(transport.isOpen()).thenReturn(false); assertFalse(conn.validate()); }
@Test public void testClose() { ThriftConnection<HelloClient> conn = new ThriftConnection<>(pool, host); conn.close(); verify(pool).put(conn); }
@Test public void testThriftConnection() throws Exception { ThriftConnection<HelloClient> conn = new ThriftConnection<>(pool, host); assertEquals(transport, conn.get()); }