thrift 0.8.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/{README → README.md} +0 -0
 - data/ext/binary_protocol_accelerated.c +33 -14
 - data/ext/bytes.c +36 -0
 - data/ext/bytes.h +31 -0
 - data/ext/compact_protocol.c +27 -8
 - data/ext/constants.h +8 -5
 - data/ext/extconf.rb +5 -1
 - data/ext/memory_buffer.c +12 -9
 - data/ext/protocol.c +0 -185
 - data/ext/protocol.h +0 -20
 - data/ext/strlcpy.h +7 -3
 - data/ext/struct.c +27 -7
 - data/ext/thrift_native.c +16 -11
 - data/lib/thrift.rb +10 -4
 - data/lib/thrift/bytes.rb +131 -0
 - data/lib/thrift/client.rb +13 -4
 - data/lib/thrift/exceptions.rb +3 -0
 - data/lib/thrift/multiplexed_processor.rb +76 -0
 - data/lib/thrift/processor.rb +24 -6
 - data/lib/thrift/protocol/base_protocol.rb +109 -12
 - data/lib/thrift/protocol/binary_protocol.rb +22 -7
 - data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
 - data/lib/thrift/protocol/compact_protocol.rb +23 -6
 - data/lib/thrift/protocol/json_protocol.rb +786 -0
 - data/lib/thrift/protocol/multiplexed_protocol.rb +44 -0
 - data/lib/thrift/protocol/protocol_decorator.rb +194 -0
 - data/lib/thrift/server/base_server.rb +8 -2
 - data/lib/thrift/server/mongrel_http_server.rb +2 -0
 - data/lib/thrift/server/simple_server.rb +5 -1
 - data/lib/thrift/server/thin_http_server.rb +91 -0
 - data/lib/thrift/server/thread_pool_server.rb +5 -1
 - data/lib/thrift/server/threaded_server.rb +5 -1
 - data/lib/thrift/struct.rb +1 -1
 - data/lib/thrift/struct_union.rb +2 -2
 - data/lib/thrift/transport/base_server_transport.rb +1 -1
 - data/lib/thrift/transport/base_transport.rb +30 -20
 - data/lib/thrift/transport/buffered_transport.rb +25 -11
 - data/lib/thrift/transport/framed_transport.rb +20 -11
 - data/lib/thrift/transport/http_client_transport.rb +16 -6
 - data/lib/thrift/transport/io_stream_transport.rb +5 -2
 - data/lib/thrift/transport/memory_buffer_transport.rb +10 -6
 - data/lib/thrift/transport/server_socket.rb +6 -1
 - data/lib/thrift/transport/socket.rb +23 -17
 - data/lib/thrift/transport/ssl_server_socket.rb +41 -0
 - data/lib/thrift/transport/ssl_socket.rb +51 -0
 - data/lib/thrift/transport/unix_server_socket.rb +5 -1
 - data/lib/thrift/transport/unix_socket.rb +5 -1
 - data/lib/thrift/union.rb +3 -6
 - data/spec/BaseService.thrift +27 -0
 - data/spec/ExtendedService.thrift +25 -0
 - data/spec/Referenced.thrift +44 -0
 - data/spec/ThriftNamespacedSpec.thrift +53 -0
 - data/spec/ThriftSpec.thrift +52 -1
 - data/spec/base_protocol_spec.rb +158 -93
 - data/spec/base_transport_spec.rb +194 -157
 - data/spec/binary_protocol_accelerated_spec.rb +14 -14
 - data/spec/binary_protocol_spec.rb +29 -16
 - data/spec/binary_protocol_spec_shared.rb +148 -65
 - data/spec/bytes_spec.rb +160 -0
 - data/spec/client_spec.rb +45 -47
 - data/spec/compact_protocol_spec.rb +36 -22
 - data/spec/exception_spec.rb +79 -80
 - data/spec/flat_spec.rb +62 -0
 - data/spec/http_client_spec.rb +91 -16
 - data/spec/json_protocol_spec.rb +552 -0
 - data/spec/namespaced_spec.rb +67 -0
 - data/spec/nonblocking_server_spec.rb +26 -28
 - data/spec/processor_spec.rb +29 -32
 - data/spec/serializer_spec.rb +31 -33
 - data/spec/server_socket_spec.rb +32 -28
 - data/spec/server_spec.rb +112 -84
 - data/spec/socket_spec.rb +27 -20
 - data/spec/socket_spec_shared.rb +32 -32
 - data/spec/spec_helper.rb +17 -11
 - data/spec/ssl_server_socket_spec.rb +34 -0
 - data/spec/ssl_socket_spec.rb +78 -0
 - data/spec/struct_nested_containers_spec.rb +191 -0
 - data/spec/struct_spec.rb +159 -161
 - data/spec/thin_http_server_spec.rb +141 -0
 - data/spec/types_spec.rb +71 -69
 - data/spec/union_spec.rb +97 -76
 - data/spec/unix_socket_spec.rb +49 -41
 - metadata +268 -188
 - data/CHANGELOG +0 -1
 - data/benchmark/gen-rb/benchmark_constants.rb +0 -10
 - data/benchmark/gen-rb/benchmark_service.rb +0 -80
 - data/benchmark/gen-rb/benchmark_types.rb +0 -9
 - data/spec/gen-rb/nonblocking_service.rb +0 -272
 - data/spec/gen-rb/thrift_spec_constants.rb +0 -10
 - data/spec/gen-rb/thrift_spec_types.rb +0 -345
 - data/spec/mongrel_http_server_spec.rb +0 -117
 - data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +0 -273
 - data/test/debug_proto/gen-rb/debug_proto_test_types.rb +0 -760
 - data/test/debug_proto/gen-rb/empty_service.rb +0 -24
 - data/test/debug_proto/gen-rb/inherited.rb +0 -79
 - data/test/debug_proto/gen-rb/reverse_order_service.rb +0 -82
 - data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +0 -81
 - data/test/debug_proto/gen-rb/srv.rb +0 -330
 
    
        data/spec/server_spec.rb
    CHANGED
    
    | 
         @@ -16,144 +16,172 @@ 
     | 
|
| 
       16 
16 
     | 
    
         
             
            # specific language governing permissions and limitations
         
     | 
| 
       17 
17 
     | 
    
         
             
            # under the License.
         
     | 
| 
       18 
18 
     | 
    
         
             
            #
         
     | 
| 
       19 
     | 
    
         
            -
            require  
     | 
| 
      
 19 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
            describe 'Server' do
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              describe Thrift::BaseServer do
         
     | 
| 
      
 24 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 25 
     | 
    
         
            +
                  @processor = double("Processor")
         
     | 
| 
      
 26 
     | 
    
         
            +
                  @serverTrans = double("ServerTransport")
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @trans = double("BaseTransport")
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @prot = double("BaseProtocol")
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @server = described_class.new(@processor, @serverTrans, @trans, @prot)
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
       23 
31 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
              describe BaseServer do
         
     | 
| 
       25 
32 
     | 
    
         
             
                it "should default to BaseTransportFactory and BinaryProtocolFactory when not specified" do
         
     | 
| 
       26 
     | 
    
         
            -
                  server = BaseServer.new( 
     | 
| 
       27 
     | 
    
         
            -
                  server.instance_variable_get(:'@transport_factory'). 
     | 
| 
       28 
     | 
    
         
            -
                  server.instance_variable_get(:'@protocol_factory'). 
     | 
| 
      
 33 
     | 
    
         
            +
                  @server = Thrift::BaseServer.new(double("Processor"), double("BaseServerTransport"))
         
     | 
| 
      
 34 
     | 
    
         
            +
                  expect(@server.instance_variable_get(:'@transport_factory')).to be_an_instance_of(Thrift::BaseTransportFactory)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  expect(@server.instance_variable_get(:'@protocol_factory')).to be_an_instance_of(Thrift::BinaryProtocolFactory)
         
     | 
| 
       29 
36 
     | 
    
         
             
                end
         
     | 
| 
       30 
37 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
      
 38 
     | 
    
         
            +
                it "should not serve" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  expect { @server.serve()}.to raise_error(NotImplementedError)
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
                
         
     | 
| 
      
 42 
     | 
    
         
            +
                it "should provide a reasonable to_s" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:to_s).once.and_return("serverTrans")
         
     | 
| 
      
 44 
     | 
    
         
            +
                  expect(@trans).to receive(:to_s).once.and_return("trans")
         
     | 
| 
      
 45 
     | 
    
         
            +
                  expect(@prot).to receive(:to_s).once.and_return("prot")
         
     | 
| 
      
 46 
     | 
    
         
            +
                  expect(@server.to_s).to eq("server(prot(trans(serverTrans)))")
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
       32 
48 
     | 
    
         
             
              end
         
     | 
| 
       33 
49 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
               
     | 
| 
      
 50 
     | 
    
         
            +
              describe Thrift::SimpleServer do
         
     | 
| 
       35 
51 
     | 
    
         
             
                before(:each) do
         
     | 
| 
       36 
     | 
    
         
            -
                  @processor =  
     | 
| 
       37 
     | 
    
         
            -
                  @serverTrans =  
     | 
| 
       38 
     | 
    
         
            -
                  @trans =  
     | 
| 
       39 
     | 
    
         
            -
                  @prot =  
     | 
| 
       40 
     | 
    
         
            -
                  @client =  
     | 
| 
       41 
     | 
    
         
            -
                  @server =  
     | 
| 
      
 52 
     | 
    
         
            +
                  @processor = double("Processor")
         
     | 
| 
      
 53 
     | 
    
         
            +
                  @serverTrans = double("ServerTransport")
         
     | 
| 
      
 54 
     | 
    
         
            +
                  @trans = double("BaseTransport")
         
     | 
| 
      
 55 
     | 
    
         
            +
                  @prot = double("BaseProtocol")
         
     | 
| 
      
 56 
     | 
    
         
            +
                  @client = double("Client")
         
     | 
| 
      
 57 
     | 
    
         
            +
                  @server = described_class.new(@processor, @serverTrans, @trans, @prot)
         
     | 
| 
       42 
58 
     | 
    
         
             
                end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                  SimpleServer
         
     | 
| 
      
 59 
     | 
    
         
            +
                
         
     | 
| 
      
 60 
     | 
    
         
            +
                it "should provide a reasonable to_s" do
         
     | 
| 
      
 61 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:to_s).once.and_return("serverTrans")
         
     | 
| 
      
 62 
     | 
    
         
            +
                  expect(@trans).to receive(:to_s).once.and_return("trans")
         
     | 
| 
      
 63 
     | 
    
         
            +
                  expect(@prot).to receive(:to_s).once.and_return("prot")
         
     | 
| 
      
 64 
     | 
    
         
            +
                  expect(@server.to_s).to eq("simple(server(prot(trans(serverTrans))))")
         
     | 
| 
       50 
65 
     | 
    
         
             
                end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
      
 66 
     | 
    
         
            +
                
         
     | 
| 
       52 
67 
     | 
    
         
             
                it "should serve in the main thread" do
         
     | 
| 
       53 
     | 
    
         
            -
                  @serverTrans. 
     | 
| 
       54 
     | 
    
         
            -
                  @serverTrans. 
     | 
| 
       55 
     | 
    
         
            -
                  @trans. 
     | 
| 
       56 
     | 
    
         
            -
                  @prot. 
     | 
| 
      
 68 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:listen).ordered
         
     | 
| 
      
 69 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:accept).exactly(3).times.and_return(@client)
         
     | 
| 
      
 70 
     | 
    
         
            +
                  expect(@trans).to receive(:get_transport).exactly(3).times.with(@client).and_return(@trans)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  expect(@prot).to receive(:get_protocol).exactly(3).times.with(@trans).and_return(@prot)
         
     | 
| 
       57 
72 
     | 
    
         
             
                  x = 0
         
     | 
| 
       58 
     | 
    
         
            -
                  @processor. 
     | 
| 
      
 73 
     | 
    
         
            +
                  expect(@processor).to receive(:process).exactly(3).times.with(@prot, @prot) do
         
     | 
| 
       59 
74 
     | 
    
         
             
                    case (x += 1)
         
     | 
| 
       60 
75 
     | 
    
         
             
                    when 1 then raise Thrift::TransportException
         
     | 
| 
       61 
76 
     | 
    
         
             
                    when 2 then raise Thrift::ProtocolException
         
     | 
| 
       62 
77 
     | 
    
         
             
                    when 3 then throw :stop
         
     | 
| 
       63 
78 
     | 
    
         
             
                    end
         
     | 
| 
       64 
79 
     | 
    
         
             
                  end
         
     | 
| 
       65 
     | 
    
         
            -
                  @trans. 
     | 
| 
       66 
     | 
    
         
            -
                  @serverTrans. 
     | 
| 
       67 
     | 
    
         
            -
                   
     | 
| 
      
 80 
     | 
    
         
            +
                  expect(@trans).to receive(:close).exactly(3).times
         
     | 
| 
      
 81 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:close).ordered
         
     | 
| 
      
 82 
     | 
    
         
            +
                  expect { @server.serve }.to throw_symbol(:stop)
         
     | 
| 
       68 
83 
     | 
    
         
             
                end
         
     | 
| 
       69 
84 
     | 
    
         
             
              end
         
     | 
| 
       70 
85 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
              describe ThreadedServer do
         
     | 
| 
       72 
     | 
    
         
            -
                 
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                   
     | 
| 
      
 86 
     | 
    
         
            +
              describe Thrift::ThreadedServer do
         
     | 
| 
      
 87 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 88 
     | 
    
         
            +
                  @processor = double("Processor")
         
     | 
| 
      
 89 
     | 
    
         
            +
                  @serverTrans = double("ServerTransport")
         
     | 
| 
      
 90 
     | 
    
         
            +
                  @trans = double("BaseTransport")
         
     | 
| 
      
 91 
     | 
    
         
            +
                  @prot = double("BaseProtocol")
         
     | 
| 
      
 92 
     | 
    
         
            +
                  @client = double("Client")
         
     | 
| 
      
 93 
     | 
    
         
            +
                  @server = described_class.new(@processor, @serverTrans, @trans, @prot)
         
     | 
| 
       76 
94 
     | 
    
         
             
                end
         
     | 
| 
       77 
95 
     | 
    
         | 
| 
      
 96 
     | 
    
         
            +
                it "should provide a reasonable to_s" do
         
     | 
| 
      
 97 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:to_s).once.and_return("serverTrans")
         
     | 
| 
      
 98 
     | 
    
         
            +
                  expect(@trans).to receive(:to_s).once.and_return("trans")
         
     | 
| 
      
 99 
     | 
    
         
            +
                  expect(@prot).to receive(:to_s).once.and_return("prot")
         
     | 
| 
      
 100 
     | 
    
         
            +
                  expect(@server.to_s).to eq("threaded(server(prot(trans(serverTrans))))")
         
     | 
| 
      
 101 
     | 
    
         
            +
                end
         
     | 
| 
      
 102 
     | 
    
         
            +
                
         
     | 
| 
       78 
103 
     | 
    
         
             
                it "should serve using threads" do
         
     | 
| 
       79 
     | 
    
         
            -
                  @serverTrans. 
     | 
| 
       80 
     | 
    
         
            -
                  @serverTrans. 
     | 
| 
       81 
     | 
    
         
            -
                  @trans. 
     | 
| 
       82 
     | 
    
         
            -
                  @prot. 
     | 
| 
       83 
     | 
    
         
            -
                  Thread. 
     | 
| 
      
 104 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:listen).ordered
         
     | 
| 
      
 105 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:accept).exactly(3).times.and_return(@client)
         
     | 
| 
      
 106 
     | 
    
         
            +
                  expect(@trans).to receive(:get_transport).exactly(3).times.with(@client).and_return(@trans)
         
     | 
| 
      
 107 
     | 
    
         
            +
                  expect(@prot).to receive(:get_protocol).exactly(3).times.with(@trans).and_return(@prot)
         
     | 
| 
      
 108 
     | 
    
         
            +
                  expect(Thread).to receive(:new).with(@prot, @trans).exactly(3).times.and_yield(@prot, @trans)
         
     | 
| 
       84 
109 
     | 
    
         
             
                  x = 0
         
     | 
| 
       85 
     | 
    
         
            -
                  @processor. 
     | 
| 
      
 110 
     | 
    
         
            +
                  expect(@processor).to receive(:process).exactly(3).times.with(@prot, @prot) do
         
     | 
| 
       86 
111 
     | 
    
         
             
                    case (x += 1)
         
     | 
| 
       87 
112 
     | 
    
         
             
                    when 1 then raise Thrift::TransportException
         
     | 
| 
       88 
113 
     | 
    
         
             
                    when 2 then raise Thrift::ProtocolException
         
     | 
| 
       89 
114 
     | 
    
         
             
                    when 3 then throw :stop
         
     | 
| 
       90 
115 
     | 
    
         
             
                    end
         
     | 
| 
       91 
116 
     | 
    
         
             
                  end
         
     | 
| 
       92 
     | 
    
         
            -
                  @trans. 
     | 
| 
       93 
     | 
    
         
            -
                  @serverTrans. 
     | 
| 
       94 
     | 
    
         
            -
                   
     | 
| 
      
 117 
     | 
    
         
            +
                  expect(@trans).to receive(:close).exactly(3).times
         
     | 
| 
      
 118 
     | 
    
         
            +
                  expect(@serverTrans).to receive(:close).ordered
         
     | 
| 
      
 119 
     | 
    
         
            +
                  expect { @server.serve }.to throw_symbol(:stop)
         
     | 
| 
       95 
120 
     | 
    
         
             
                end
         
     | 
| 
       96 
121 
     | 
    
         
             
              end
         
     | 
| 
       97 
122 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
              describe ThreadPoolServer do
         
     | 
| 
       99 
     | 
    
         
            -
                 
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                   
     | 
| 
       103 
     | 
    
         
            -
                  @ 
     | 
| 
       104 
     | 
    
         
            -
                   
     | 
| 
       105 
     | 
    
         
            -
                  @ 
     | 
| 
       106 
     | 
    
         
            -
                   
     | 
| 
       107 
     | 
    
         
            -
                  ThreadPoolServer
         
     | 
| 
      
 123 
     | 
    
         
            +
              describe Thrift::ThreadPoolServer do
         
     | 
| 
      
 124 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 125 
     | 
    
         
            +
                  @processor = double("Processor")
         
     | 
| 
      
 126 
     | 
    
         
            +
                  @server_trans = double("ServerTransport")
         
     | 
| 
      
 127 
     | 
    
         
            +
                  @trans = double("BaseTransport")
         
     | 
| 
      
 128 
     | 
    
         
            +
                  @prot = double("BaseProtocol")
         
     | 
| 
      
 129 
     | 
    
         
            +
                  @client = double("Client")
         
     | 
| 
      
 130 
     | 
    
         
            +
                  @server = described_class.new(@processor, @server_trans, @trans, @prot)
         
     | 
| 
      
 131 
     | 
    
         
            +
                  sleep(0.15)
         
     | 
| 
       108 
132 
     | 
    
         
             
                end
         
     | 
| 
       109 
133 
     | 
    
         | 
| 
       110 
     | 
    
         
            -
                it "should  
     | 
| 
       111 
     | 
    
         
            -
                  @ 
     | 
| 
       112 
     | 
    
         
            -
                  @ 
     | 
| 
      
 134 
     | 
    
         
            +
                it "should provide a reasonable to_s" do
         
     | 
| 
      
 135 
     | 
    
         
            +
                  expect(@server_trans).to receive(:to_s).once.and_return("server_trans")
         
     | 
| 
      
 136 
     | 
    
         
            +
                  expect(@trans).to receive(:to_s).once.and_return("trans")
         
     | 
| 
      
 137 
     | 
    
         
            +
                  expect(@prot).to receive(:to_s).once.and_return("prot")
         
     | 
| 
      
 138 
     | 
    
         
            +
                  expect(@server.to_s).to eq("threadpool(server(prot(trans(server_trans))))")
         
     | 
| 
       113 
139 
     | 
    
         
             
                end
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
      
 140 
     | 
    
         
            +
                
         
     | 
| 
       115 
141 
     | 
    
         
             
                it "should serve inside a thread" do
         
     | 
| 
       116 
     | 
    
         
            -
                   
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
                     
     | 
| 
       119 
     | 
    
         
            -
                    @server.rspec_verify
         
     | 
| 
      
 142 
     | 
    
         
            +
                  exception_q = @server.instance_variable_get(:@exception_q)
         
     | 
| 
      
 143 
     | 
    
         
            +
                  expect_any_instance_of(described_class).to receive(:serve) do 
         
     | 
| 
      
 144 
     | 
    
         
            +
                    exception_q.push(StandardError.new('ERROR'))
         
     | 
| 
       120 
145 
     | 
    
         
             
                  end
         
     | 
| 
       121 
     | 
    
         
            -
                  @ 
     | 
| 
       122 
     | 
    
         
            -
                   
     | 
| 
      
 146 
     | 
    
         
            +
                  expect { @server.rescuable_serve }.to(raise_error('ERROR'))
         
     | 
| 
      
 147 
     | 
    
         
            +
                  sleep(0.15)
         
     | 
| 
       123 
148 
     | 
    
         
             
                end
         
     | 
| 
       124 
149 
     | 
    
         | 
| 
       125 
150 
     | 
    
         
             
                it "should avoid running the server twice when retrying rescuable_serve" do
         
     | 
| 
       126 
     | 
    
         
            -
                   
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
                     
     | 
| 
       129 
     | 
    
         
            -
                     
     | 
| 
      
 151 
     | 
    
         
            +
                  exception_q = @server.instance_variable_get(:@exception_q)
         
     | 
| 
      
 152 
     | 
    
         
            +
                  expect_any_instance_of(described_class).to receive(:serve) do 
         
     | 
| 
      
 153 
     | 
    
         
            +
                    exception_q.push(StandardError.new('ERROR1'))
         
     | 
| 
      
 154 
     | 
    
         
            +
                    exception_q.push(StandardError.new('ERROR2'))
         
     | 
| 
       130 
155 
     | 
    
         
             
                  end
         
     | 
| 
       131 
     | 
    
         
            -
                  @ 
     | 
| 
       132 
     | 
    
         
            -
                   
     | 
| 
       133 
     | 
    
         
            -
                  lambda { @server.rescuable_serve }.should throw_symbol(:popped)
         
     | 
| 
      
 156 
     | 
    
         
            +
                  expect { @server.rescuable_serve }.to(raise_error('ERROR1'))
         
     | 
| 
      
 157 
     | 
    
         
            +
                  expect { @server.rescuable_serve }.to(raise_error('ERROR2'))
         
     | 
| 
       134 
158 
     | 
    
         
             
                end
         
     | 
| 
       135 
159 
     | 
    
         | 
| 
       136 
160 
     | 
    
         
             
                it "should serve using a thread pool" do
         
     | 
| 
       137 
     | 
    
         
            -
                   
     | 
| 
       138 
     | 
    
         
            -
                   
     | 
| 
       139 
     | 
    
         
            -
                  @ 
     | 
| 
       140 
     | 
    
         
            -
                   
     | 
| 
       141 
     | 
    
         
            -
                  @ 
     | 
| 
       142 
     | 
    
         
            -
                   
     | 
| 
       143 
     | 
    
         
            -
                   
     | 
| 
      
 161 
     | 
    
         
            +
                  thread_q = double("SizedQueue")
         
     | 
| 
      
 162 
     | 
    
         
            +
                  exception_q = double("Queue")
         
     | 
| 
      
 163 
     | 
    
         
            +
                  @server.instance_variable_set(:@thread_q, thread_q)
         
     | 
| 
      
 164 
     | 
    
         
            +
                  @server.instance_variable_set(:@exception_q, exception_q)
         
     | 
| 
      
 165 
     | 
    
         
            +
                  expect(@server_trans).to receive(:listen).ordered
         
     | 
| 
      
 166 
     | 
    
         
            +
                  expect(thread_q).to receive(:push).with(:token)
         
     | 
| 
      
 167 
     | 
    
         
            +
                  expect(thread_q).to receive(:pop)
         
     | 
| 
      
 168 
     | 
    
         
            +
                  expect(Thread).to receive(:new).and_yield
         
     | 
| 
      
 169 
     | 
    
         
            +
                  expect(@server_trans).to receive(:accept).exactly(3).times.and_return(@client)
         
     | 
| 
      
 170 
     | 
    
         
            +
                  expect(@trans).to receive(:get_transport).exactly(3).times.and_return(@trans)
         
     | 
| 
      
 171 
     | 
    
         
            +
                  expect(@prot).to receive(:get_protocol).exactly(3).times.and_return(@prot)
         
     | 
| 
       144 
172 
     | 
    
         
             
                  x = 0
         
     | 
| 
       145 
173 
     | 
    
         
             
                  error = RuntimeError.new("Stopped")
         
     | 
| 
       146 
     | 
    
         
            -
                  @processor. 
     | 
| 
      
 174 
     | 
    
         
            +
                  expect(@processor).to receive(:process).exactly(3).times.with(@prot, @prot) do
         
     | 
| 
       147 
175 
     | 
    
         
             
                    case (x += 1)
         
     | 
| 
       148 
176 
     | 
    
         
             
                    when 1 then raise Thrift::TransportException
         
     | 
| 
       149 
177 
     | 
    
         
             
                    when 2 then raise Thrift::ProtocolException
         
     | 
| 
       150 
178 
     | 
    
         
             
                    when 3 then raise error
         
     | 
| 
       151 
179 
     | 
    
         
             
                    end
         
     | 
| 
       152 
180 
     | 
    
         
             
                  end
         
     | 
| 
       153 
     | 
    
         
            -
                  @trans. 
     | 
| 
       154 
     | 
    
         
            -
                   
     | 
| 
       155 
     | 
    
         
            -
                  @ 
     | 
| 
       156 
     | 
    
         
            -
                   
     | 
| 
      
 181 
     | 
    
         
            +
                  expect(@trans).to receive(:close).exactly(3).times
         
     | 
| 
      
 182 
     | 
    
         
            +
                  expect(exception_q).to receive(:push).with(error).and_throw(:stop)
         
     | 
| 
      
 183 
     | 
    
         
            +
                  expect(@server_trans).to receive(:close)
         
     | 
| 
      
 184 
     | 
    
         
            +
                  expect { @server.serve }.to(throw_symbol(:stop))
         
     | 
| 
       157 
185 
     | 
    
         
             
                end
         
     | 
| 
       158 
186 
     | 
    
         
             
              end
         
     | 
| 
       159 
187 
     | 
    
         
             
            end
         
     | 
    
        data/spec/socket_spec.rb
    CHANGED
    
    | 
         @@ -17,45 +17,52 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
            # under the License.
         
     | 
| 
       18 
18 
     | 
    
         
             
            #
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            require  
     | 
| 
      
 20 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
       21 
21 
     | 
    
         
             
            require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              include Thrift
         
     | 
| 
      
 23 
     | 
    
         
            +
            describe 'Socket' do
         
     | 
| 
       25 
24 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
              describe Socket do
         
     | 
| 
      
 25 
     | 
    
         
            +
              describe Thrift::Socket do
         
     | 
| 
       27 
26 
     | 
    
         
             
                before(:each) do
         
     | 
| 
       28 
     | 
    
         
            -
                  @socket = Socket.new
         
     | 
| 
       29 
     | 
    
         
            -
                  @handle =  
     | 
| 
       30 
     | 
    
         
            -
                  @handle. 
     | 
| 
       31 
     | 
    
         
            -
                  @handle. 
     | 
| 
       32 
     | 
    
         
            -
                   
     | 
| 
      
 27 
     | 
    
         
            +
                  @socket = Thrift::Socket.new
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @handle = double("Handle", :closed? => false)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  allow(@handle).to receive(:close)
         
     | 
| 
      
 30 
     | 
    
         
            +
                  allow(@handle).to receive(:connect_nonblock)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  allow(@handle).to receive(:setsockopt)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  allow(::Socket).to receive(:new).and_return(@handle)
         
     | 
| 
       33 
33 
     | 
    
         
             
                end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
35 
     | 
    
         
             
                it_should_behave_like "a socket"
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
       37 
37 
     | 
    
         
             
                it "should raise a TransportException when it cannot open a socket" do
         
     | 
| 
       38 
     | 
    
         
            -
                  ::Socket. 
     | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
      
 38 
     | 
    
         
            +
                  expect(::Socket).to receive(:getaddrinfo).with("localhost", 9090, nil, ::Socket::SOCK_STREAM).and_return([[]])
         
     | 
| 
      
 39 
     | 
    
         
            +
                  expect { @socket.open }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::NOT_OPEN) }
         
     | 
| 
       40 
40 
     | 
    
         
             
                end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
                it "should open a ::Socket with default args" do
         
     | 
| 
       43 
     | 
    
         
            -
                  ::Socket. 
     | 
| 
       44 
     | 
    
         
            -
                  ::Socket. 
     | 
| 
       45 
     | 
    
         
            -
                  ::Socket. 
     | 
| 
      
 43 
     | 
    
         
            +
                  expect(::Socket).to receive(:new).and_return(double("Handle", :connect_nonblock => true, :setsockopt => nil))
         
     | 
| 
      
 44 
     | 
    
         
            +
                  expect(::Socket).to receive(:getaddrinfo).with("localhost", 9090, nil, ::Socket::SOCK_STREAM).and_return([[]])
         
     | 
| 
      
 45 
     | 
    
         
            +
                  expect(::Socket).to receive(:sockaddr_in)
         
     | 
| 
      
 46 
     | 
    
         
            +
                  @socket.to_s == "socket(localhost:9090)"
         
     | 
| 
       46 
47 
     | 
    
         
             
                  @socket.open
         
     | 
| 
       47 
48 
     | 
    
         
             
                end
         
     | 
| 
       48 
49 
     | 
    
         | 
| 
       49 
50 
     | 
    
         
             
                it "should accept host/port options" do
         
     | 
| 
       50 
     | 
    
         
            -
                  ::Socket. 
     | 
| 
       51 
     | 
    
         
            -
                  ::Socket. 
     | 
| 
       52 
     | 
    
         
            -
                  ::Socket. 
     | 
| 
       53 
     | 
    
         
            -
                  Socket.new('my.domain', 1234).open
         
     | 
| 
      
 51 
     | 
    
         
            +
                  expect(::Socket).to receive(:new).and_return(double("Handle", :connect_nonblock => true, :setsockopt => nil))
         
     | 
| 
      
 52 
     | 
    
         
            +
                  expect(::Socket).to receive(:getaddrinfo).with("my.domain", 1234, nil, ::Socket::SOCK_STREAM).and_return([[]])
         
     | 
| 
      
 53 
     | 
    
         
            +
                  expect(::Socket).to receive(:sockaddr_in)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  @socket = Thrift::Socket.new('my.domain', 1234).open
         
     | 
| 
      
 55 
     | 
    
         
            +
                  @socket.to_s == "socket(my.domain:1234)"
         
     | 
| 
       54 
56 
     | 
    
         
             
                end
         
     | 
| 
       55 
57 
     | 
    
         | 
| 
       56 
58 
     | 
    
         
             
                it "should accept an optional timeout" do
         
     | 
| 
       57 
     | 
    
         
            -
                  ::Socket. 
     | 
| 
       58 
     | 
    
         
            -
                  Socket.new('localhost', 8080, 5).timeout. 
     | 
| 
      
 59 
     | 
    
         
            +
                  allow(::Socket).to receive(:new)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  expect(Thrift::Socket.new('localhost', 8080, 5).timeout).to eq(5)
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                it "should provide a reasonable to_s" do
         
     | 
| 
      
 64 
     | 
    
         
            +
                  allow(::Socket).to receive(:new)
         
     | 
| 
      
 65 
     | 
    
         
            +
                  expect(Thrift::Socket.new('myhost', 8090).to_s).to eq("socket(myhost:8090)")
         
     | 
| 
       59 
66 
     | 
    
         
             
                end
         
     | 
| 
       60 
67 
     | 
    
         
             
              end
         
     | 
| 
       61 
68 
     | 
    
         
             
            end
         
     | 
    
        data/spec/socket_spec_shared.rb
    CHANGED
    
    | 
         @@ -17,88 +17,88 @@ 
     | 
|
| 
       17 
17 
     | 
    
         
             
            # under the License.
         
     | 
| 
       18 
18 
     | 
    
         
             
            #
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            require  
     | 
| 
      
 20 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            shared_examples_for "a socket" do
         
     | 
| 
       23 
23 
     | 
    
         
             
              it "should open a socket" do
         
     | 
| 
       24 
     | 
    
         
            -
                @socket.open. 
     | 
| 
      
 24 
     | 
    
         
            +
                expect(@socket.open).to eq(@handle)
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
              it "should be open whenever it has a handle" do
         
     | 
| 
       28 
     | 
    
         
            -
                @socket. 
     | 
| 
      
 28 
     | 
    
         
            +
                expect(@socket).not_to be_open
         
     | 
| 
       29 
29 
     | 
    
         
             
                @socket.open
         
     | 
| 
       30 
     | 
    
         
            -
                @socket. 
     | 
| 
      
 30 
     | 
    
         
            +
                expect(@socket).to be_open
         
     | 
| 
       31 
31 
     | 
    
         
             
                @socket.handle = nil
         
     | 
| 
       32 
     | 
    
         
            -
                @socket. 
     | 
| 
      
 32 
     | 
    
         
            +
                expect(@socket).not_to be_open
         
     | 
| 
       33 
33 
     | 
    
         
             
                @socket.handle = @handle
         
     | 
| 
       34 
34 
     | 
    
         
             
                @socket.close
         
     | 
| 
       35 
     | 
    
         
            -
                @socket. 
     | 
| 
      
 35 
     | 
    
         
            +
                expect(@socket).not_to be_open
         
     | 
| 
       36 
36 
     | 
    
         
             
              end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
              it "should write data to the handle" do
         
     | 
| 
       39 
39 
     | 
    
         
             
                @socket.open
         
     | 
| 
       40 
     | 
    
         
            -
                @handle. 
     | 
| 
      
 40 
     | 
    
         
            +
                expect(@handle).to receive(:write).with("foobar")
         
     | 
| 
       41 
41 
     | 
    
         
             
                @socket.write("foobar")
         
     | 
| 
       42 
     | 
    
         
            -
                @handle. 
     | 
| 
       43 
     | 
    
         
            -
                 
     | 
| 
      
 42 
     | 
    
         
            +
                expect(@handle).to receive(:write).with("fail").and_raise(StandardError)
         
     | 
| 
      
 43 
     | 
    
         
            +
                expect { @socket.write("fail") }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::NOT_OPEN) }
         
     | 
| 
       44 
44 
     | 
    
         
             
              end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
              it "should raise an error when it cannot read from the handle" do
         
     | 
| 
       47 
47 
     | 
    
         
             
                @socket.open
         
     | 
| 
       48 
     | 
    
         
            -
                @handle. 
     | 
| 
       49 
     | 
    
         
            -
                 
     | 
| 
      
 48 
     | 
    
         
            +
                expect(@handle).to receive(:readpartial).with(17).and_raise(StandardError)
         
     | 
| 
      
 49 
     | 
    
         
            +
                expect { @socket.read(17) }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::NOT_OPEN) }
         
     | 
| 
       50 
50 
     | 
    
         
             
              end
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
52 
     | 
    
         
             
              it "should return the data read when reading from the handle works" do
         
     | 
| 
       53 
53 
     | 
    
         
             
                @socket.open
         
     | 
| 
       54 
     | 
    
         
            -
                @handle. 
     | 
| 
       55 
     | 
    
         
            -
                @socket.read(17). 
     | 
| 
      
 54 
     | 
    
         
            +
                expect(@handle).to receive(:readpartial).with(17).and_return("test data")
         
     | 
| 
      
 55 
     | 
    
         
            +
                expect(@socket.read(17)).to eq("test data")
         
     | 
| 
       56 
56 
     | 
    
         
             
              end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
              it "should declare itself as closed when it has an error" do
         
     | 
| 
       59 
59 
     | 
    
         
             
                @socket.open
         
     | 
| 
       60 
     | 
    
         
            -
                @handle. 
     | 
| 
       61 
     | 
    
         
            -
                @socket. 
     | 
| 
       62 
     | 
    
         
            -
                 
     | 
| 
       63 
     | 
    
         
            -
                @socket. 
     | 
| 
      
 60 
     | 
    
         
            +
                expect(@handle).to receive(:write).with("fail").and_raise(StandardError)
         
     | 
| 
      
 61 
     | 
    
         
            +
                expect(@socket).to be_open
         
     | 
| 
      
 62 
     | 
    
         
            +
                expect { @socket.write("fail") }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::NOT_OPEN) }
         
     | 
| 
      
 63 
     | 
    
         
            +
                expect(@socket).not_to be_open
         
     | 
| 
       64 
64 
     | 
    
         
             
              end
         
     | 
| 
       65 
65 
     | 
    
         | 
| 
       66 
66 
     | 
    
         
             
              it "should raise an error when the stream is closed" do
         
     | 
| 
       67 
67 
     | 
    
         
             
                @socket.open
         
     | 
| 
       68 
     | 
    
         
            -
                @handle. 
     | 
| 
       69 
     | 
    
         
            -
                @socket. 
     | 
| 
       70 
     | 
    
         
            -
                 
     | 
| 
       71 
     | 
    
         
            -
                 
     | 
| 
      
 68 
     | 
    
         
            +
                allow(@handle).to receive(:closed?).and_return(true)
         
     | 
| 
      
 69 
     | 
    
         
            +
                expect(@socket).not_to be_open
         
     | 
| 
      
 70 
     | 
    
         
            +
                expect { @socket.write("fail") }.to raise_error(IOError, "closed stream")
         
     | 
| 
      
 71 
     | 
    
         
            +
                expect { @socket.read(10) }.to raise_error(IOError, "closed stream")
         
     | 
| 
       72 
72 
     | 
    
         
             
              end
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
              it "should support the timeout accessor for read" do
         
     | 
| 
       75 
75 
     | 
    
         
             
                @socket.timeout = 3
         
     | 
| 
       76 
76 
     | 
    
         
             
                @socket.open
         
     | 
| 
       77 
     | 
    
         
            -
                IO. 
     | 
| 
       78 
     | 
    
         
            -
                @handle. 
     | 
| 
       79 
     | 
    
         
            -
                @socket.read(17). 
     | 
| 
      
 77 
     | 
    
         
            +
                expect(IO).to receive(:select).with([@handle], nil, nil, 3).and_return([[@handle], [], []])
         
     | 
| 
      
 78 
     | 
    
         
            +
                expect(@handle).to receive(:readpartial).with(17).and_return("test data")
         
     | 
| 
      
 79 
     | 
    
         
            +
                expect(@socket.read(17)).to eq("test data")
         
     | 
| 
       80 
80 
     | 
    
         
             
              end
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
       82 
82 
     | 
    
         
             
              it "should support the timeout accessor for write" do
         
     | 
| 
       83 
83 
     | 
    
         
             
                @socket.timeout = 3
         
     | 
| 
       84 
84 
     | 
    
         
             
                @socket.open
         
     | 
| 
       85 
     | 
    
         
            -
                IO. 
     | 
| 
       86 
     | 
    
         
            -
                @handle. 
     | 
| 
       87 
     | 
    
         
            -
                @handle. 
     | 
| 
       88 
     | 
    
         
            -
                @socket.write("test data"). 
     | 
| 
      
 85 
     | 
    
         
            +
                expect(IO).to receive(:select).with(nil, [@handle], nil, 3).twice.and_return([[], [@handle], []])
         
     | 
| 
      
 86 
     | 
    
         
            +
                expect(@handle).to receive(:write_nonblock).with("test data").and_return(4)
         
     | 
| 
      
 87 
     | 
    
         
            +
                expect(@handle).to receive(:write_nonblock).with(" data").and_return(5)
         
     | 
| 
      
 88 
     | 
    
         
            +
                expect(@socket.write("test data")).to eq(9)
         
     | 
| 
       89 
89 
     | 
    
         
             
              end
         
     | 
| 
       90 
90 
     | 
    
         | 
| 
       91 
91 
     | 
    
         
             
              it "should raise an error when read times out" do
         
     | 
| 
       92 
92 
     | 
    
         
             
                @socket.timeout = 0.5
         
     | 
| 
       93 
93 
     | 
    
         
             
                @socket.open
         
     | 
| 
       94 
     | 
    
         
            -
                IO. 
     | 
| 
       95 
     | 
    
         
            -
                 
     | 
| 
      
 94 
     | 
    
         
            +
                expect(IO).to receive(:select).once {sleep(0.5); nil}
         
     | 
| 
      
 95 
     | 
    
         
            +
                expect { @socket.read(17) }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::TIMED_OUT) }
         
     | 
| 
       96 
96 
     | 
    
         
             
              end
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
              it "should raise an error when write times out" do
         
     | 
| 
       99 
99 
     | 
    
         
             
                @socket.timeout = 0.5
         
     | 
| 
       100 
100 
     | 
    
         
             
                @socket.open
         
     | 
| 
       101 
     | 
    
         
            -
                IO. 
     | 
| 
       102 
     | 
    
         
            -
                 
     | 
| 
      
 101 
     | 
    
         
            +
                allow(IO).to receive(:select).with(nil, [@handle], nil, 0.5).and_return(nil)
         
     | 
| 
      
 102 
     | 
    
         
            +
                expect { @socket.write("test data") }.to raise_error(Thrift::TransportException) { |e| expect(e.type).to eq(Thrift::TransportException::TIMED_OUT) }
         
     | 
| 
       103 
103 
     | 
    
         
             
              end
         
     | 
| 
       104 
104 
     | 
    
         
             
            end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,3 +1,4 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: UTF-8
         
     | 
| 
       1 
2 
     | 
    
         
             
            #
         
     | 
| 
       2 
3 
     | 
    
         
             
            # Licensed to the Apache Software Foundation (ASF) under one
         
     | 
| 
       3 
4 
     | 
    
         
             
            # or more contributor license agreements. See the NOTICE file
         
     | 
| 
         @@ -18,7 +19,7 @@ 
     | 
|
| 
       18 
19 
     | 
    
         
             
            #
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       21 
     | 
    
         
            -
            require ' 
     | 
| 
      
 22 
     | 
    
         
            +
            require 'rspec'
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
24 
     | 
    
         
             
            $:.unshift File.join(File.dirname(__FILE__), *%w[.. ext])
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
         @@ -26,33 +27,38 @@ $:.unshift File.join(File.dirname(__FILE__), *%w[.. ext]) 
     | 
|
| 
       26 
27 
     | 
    
         
             
            # will get screwed up
         
     | 
| 
       27 
28 
     | 
    
         
             
            # $" << 'fastthread.bundle'
         
     | 
| 
       28 
29 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
            require  
     | 
| 
      
 30 
     | 
    
         
            +
            require 'thrift'
         
     | 
| 
       30 
31 
     | 
    
         | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
              #  
     | 
| 
       33 
     | 
    
         
            -
               
     | 
| 
       34 
     | 
    
         
            -
                block 
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
            unless Object.method_defined? :tap
         
     | 
| 
      
 33 
     | 
    
         
            +
              # if Object#tap isn't defined, then add it; this should only happen in Ruby < 1.8.7
         
     | 
| 
      
 34 
     | 
    
         
            +
              class Object
         
     | 
| 
      
 35 
     | 
    
         
            +
                def tap(&block)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  block.call(self)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  self
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
       36 
39 
     | 
    
         
             
              end
         
     | 
| 
       37 
40 
     | 
    
         
             
            end
         
     | 
| 
       38 
41 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
            RSpec.configure do |configuration|
         
     | 
| 
       40 
43 
     | 
    
         
             
              configuration.before(:each) do
         
     | 
| 
       41 
44 
     | 
    
         
             
                Thrift.type_checking = true
         
     | 
| 
       42 
45 
     | 
    
         
             
              end
         
     | 
| 
       43 
46 
     | 
    
         
             
            end
         
     | 
| 
       44 
47 
     | 
    
         | 
| 
       45 
48 
     | 
    
         
             
            $:.unshift File.join(File.dirname(__FILE__), *%w[.. test debug_proto gen-rb])
         
     | 
| 
       46 
     | 
    
         
            -
            require  
     | 
| 
       47 
     | 
    
         
            -
            require  
     | 
| 
      
 49 
     | 
    
         
            +
            require 'srv'
         
     | 
| 
      
 50 
     | 
    
         
            +
            require 'debug_proto_test_constants'
         
     | 
| 
       48 
51 
     | 
    
         | 
| 
       49 
52 
     | 
    
         
             
            $:.unshift File.join(File.dirname(__FILE__), *%w[gen-rb])
         
     | 
| 
       50 
53 
     | 
    
         
             
            require 'thrift_spec_types'
         
     | 
| 
       51 
54 
     | 
    
         
             
            require 'nonblocking_service'
         
     | 
| 
       52 
55 
     | 
    
         | 
| 
       53 
56 
     | 
    
         
             
            module Fixtures
         
     | 
| 
       54 
     | 
    
         
            -
              COMPACT_PROTOCOL_TEST_STRUCT = COMPACT_TEST.dup
         
     | 
| 
      
 57 
     | 
    
         
            +
              COMPACT_PROTOCOL_TEST_STRUCT = Thrift::Test::COMPACT_TEST.dup
         
     | 
| 
       55 
58 
     | 
    
         
             
              COMPACT_PROTOCOL_TEST_STRUCT.a_binary = [0,1,2,3,4,5,6,7,8].pack('c*')
         
     | 
| 
       56 
59 
     | 
    
         
             
              COMPACT_PROTOCOL_TEST_STRUCT.set_byte_map = nil
         
     | 
| 
       57 
60 
     | 
    
         
             
              COMPACT_PROTOCOL_TEST_STRUCT.map_byte_map = nil
         
     | 
| 
       58 
61 
     | 
    
         
             
            end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            $:.unshift File.join(File.dirname(__FILE__), *%w[gen-rb/flat])
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     |