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

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

Introduction

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

Prototype

TTransport

Source Link

Usage

From source file:org.apache.hadoop.hive.serde2.TestTCTLSeparatedProtocol.java

License:Apache License

public void testShouldThrowRunTimeExceptionIfUnableToInitializeTokenizer() throws Exception {
    TCTLSeparatedProtocol separatedProtocol = new TCTLSeparatedProtocol(new TTransport() {
        @Override/*from   w  ww.  j  av a2s  . co m*/
        public void close() {
        }

        @Override
        public boolean isOpen() {
            return false;
        }

        @Override
        public void open() throws TTransportException {
        }

        @Override
        public int read(byte[] buf, int off, int len) throws TTransportException {
            throw new TTransportException();
        }

        @Override
        public void write(byte[] buf, int off, int len) throws TTransportException {
        }
    });
    separatedProtocol.initialize(null, new Properties());
    try {
        separatedProtocol.readStructBegin();
        fail("Runtime Exception is expected if the intialization of tokenizer failed.");
    } catch (Exception e) {
        assertTrue(e.getCause() instanceof TTransportException);
    }
}