Example usage for org.apache.thrift.transport TTransport readAll

List of usage examples for org.apache.thrift.transport TTransport readAll

Introduction

In this page you can find the example usage for org.apache.thrift.transport TTransport readAll.

Prototype

public int readAll(byte[] buf, int off, int len) throws TTransportException 

Source Link

Document

Guarantees that all of len bytes are actually read off the transport.

Usage

From source file:org.janusgraph.graphdb.thrift.ThriftConnectionTest.java

License:Apache License

@Test
public void testConnectionDropped() throws Exception {
    CTConnectionFactory connectionFactory = spy(factoryConfig.build());
    CTConnection mockConnection = spy(connectionFactory.makeObject("janusgraph"));

    when(mockConnection.getConfig()).thenReturn(factoryConfig);
    when(mockConnection.isOpen()).thenReturn(true);
    TTransport mockClient = spy(mockConnection.getTransport());

    assertTrue(connectionFactory.validateObject(null, mockConnection));
    when(mockClient.readAll(new byte[0], 0, 0)).thenThrow(new TTransportException("Broken Pipe"));
    assertTrue(mockClient.isOpen());/*from  ww  w.j av a2 s . co  m*/
}