Search in sources :

Example 1 with CTConnectionFactory

use of org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory in project janusgraph by JanusGraph.

the class ThriftConnectionTest method testConnectionDropped.

@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());
}
Also used : CTConnection(org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnection) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) CTConnectionFactory(org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory) Test(org.junit.Test)

Aggregations

TTransport (org.apache.thrift.transport.TTransport)1 TTransportException (org.apache.thrift.transport.TTransportException)1 CTConnection (org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnection)1 CTConnectionFactory (org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory)1 Test (org.junit.Test)1