thrift 0.24.0 → 0.25.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 +4 -4
- data/README.md +107 -4
- data/ext/binary_protocol_accelerated.c +52 -17
- data/ext/compact_protocol.c +135 -70
- data/ext/constants.h +3 -0
- data/ext/extconf.rb +4 -4
- data/ext/macros.h +11 -0
- data/ext/memory_buffer.c +35 -17
- data/ext/struct.c +185 -64
- data/ext/thrift_native.c +6 -0
- data/lib/thrift/bytes.rb +2 -2
- data/lib/thrift/client.rb +31 -22
- data/lib/thrift/exceptions.rb +10 -8
- data/lib/thrift/multiplexed_processor.rb +5 -6
- data/lib/thrift/processor.rb +24 -3
- data/lib/thrift/protocol/base_protocol.rb +53 -27
- data/lib/thrift/protocol/binary_protocol.rb +54 -40
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +6 -2
- data/lib/thrift/protocol/compact_protocol.rb +193 -88
- data/lib/thrift/protocol/header_protocol.rb +14 -3
- data/lib/thrift/protocol/json_protocol.rb +146 -104
- data/lib/thrift/protocol/multiplexed_protocol.rb +2 -3
- data/lib/thrift/protocol/protocol_decorator.rb +5 -2
- data/lib/thrift/serializer/serializer.rb +6 -0
- data/lib/thrift/server/base_server.rb +10 -2
- data/lib/thrift/server/nonblocking_server.rb +49 -26
- data/lib/thrift/server/rack_application.rb +69 -0
- data/lib/thrift/server/simple_server.rb +27 -23
- data/lib/thrift/server/thin_http_server.rb +20 -44
- data/lib/thrift/server/thread_pool_server.rb +20 -17
- data/lib/thrift/server/threaded_server.rb +22 -26
- data/lib/thrift/struct.rb +33 -18
- data/lib/thrift/struct_union.rb +36 -30
- data/lib/thrift/transport/base_transport.rb +23 -5
- data/lib/thrift/transport/buffered_transport.rb +4 -4
- data/lib/thrift/transport/framed_transport.rb +32 -7
- data/lib/thrift/transport/header_transport.rb +130 -50
- data/lib/thrift/transport/http_client_transport.rb +27 -14
- data/lib/thrift/transport/io_stream_transport.rb +2 -1
- data/lib/thrift/transport/memory_buffer_transport.rb +8 -10
- data/lib/thrift/transport/server_socket.rb +4 -5
- data/lib/thrift/transport/socket.rb +20 -22
- data/lib/thrift/transport/ssl_server_socket.rb +64 -4
- data/lib/thrift/transport/ssl_socket.rb +32 -5
- data/lib/thrift/transport/unix_server_socket.rb +1 -1
- data/lib/thrift/transport/unix_socket.rb +4 -6
- data/lib/thrift/types.rb +22 -22
- data/lib/thrift/union.rb +20 -11
- data/lib/thrift/uuid.rb +8 -8
- data/lib/thrift.rb +39 -39
- metadata +5 -230
- data/benchmark/Benchmark.thrift +0 -24
- data/benchmark/benchmark.rb +0 -286
- data/benchmark/client.rb +0 -118
- data/benchmark/server.rb +0 -121
- data/benchmark/thin_server.rb +0 -46
- data/lib/thrift/server/mongrel_http_server.rb +0 -61
- data/spec/BaseService.thrift +0 -27
- data/spec/ExtendedService.thrift +0 -25
- data/spec/Referenced.thrift +0 -44
- data/spec/ThriftNamespacedSpec.thrift +0 -53
- data/spec/ThriftSpec.thrift +0 -203
- data/spec/base_protocol_spec.rb +0 -244
- data/spec/base_transport_spec.rb +0 -428
- data/spec/binary_protocol_accelerated_spec.rb +0 -47
- data/spec/binary_protocol_spec.rb +0 -73
- data/spec/binary_protocol_spec_shared.rb +0 -509
- data/spec/bytes_spec.rb +0 -117
- data/spec/client_spec.rb +0 -167
- data/spec/compact_protocol_spec.rb +0 -295
- data/spec/constants_demo_spec.rb +0 -102
- data/spec/exception_spec.rb +0 -141
- data/spec/flat_spec.rb +0 -63
- data/spec/header_protocol_spec.rb +0 -476
- data/spec/header_transport_spec.rb +0 -431
- data/spec/http_client_spec.rb +0 -160
- data/spec/json_protocol_spec.rb +0 -574
- data/spec/multiplexed_processor_spec.rb +0 -75
- data/spec/namespaced_spec.rb +0 -67
- data/spec/nonblocking_server_spec.rb +0 -429
- data/spec/processor_spec.rb +0 -80
- data/spec/recursion_depth_spec.rb +0 -223
- data/spec/serializer_spec.rb +0 -67
- data/spec/server_socket_spec.rb +0 -121
- data/spec/server_spec.rb +0 -238
- data/spec/socket_spec.rb +0 -174
- data/spec/socket_spec_shared.rb +0 -168
- data/spec/spec_helper.rb +0 -70
- data/spec/ssl_server_socket_spec.rb +0 -85
- data/spec/ssl_socket_spec.rb +0 -248
- data/spec/struct_nested_containers_spec.rb +0 -191
- data/spec/struct_spec.rb +0 -398
- data/spec/support/header_protocol_helper.rb +0 -55
- data/spec/thin_http_server_spec.rb +0 -127
- data/spec/types_spec.rb +0 -118
- data/spec/union_spec.rb +0 -273
- data/spec/unix_socket_spec.rb +0 -131
- data/spec/uuid_validation_spec.rb +0 -239
- data/test/fuzz/Makefile +0 -779
- data/test/fuzz/Makefile.am +0 -173
- data/test/fuzz/Makefile.in +0 -775
- data/test/fuzz/README.md +0 -149
- data/test/fuzz/fuzz_common.rb +0 -96
- data/test/fuzz/fuzz_parse_binary_protocol.rb +0 -23
- data/test/fuzz/fuzz_parse_binary_protocol_accelerated.rb +0 -23
- data/test/fuzz/fuzz_parse_binary_protocol_accelerated_harness.rb +0 -23
- data/test/fuzz/fuzz_parse_binary_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_parse_compact_protocol.rb +0 -23
- data/test/fuzz/fuzz_parse_compact_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_parse_json_protocol.rb +0 -23
- data/test/fuzz/fuzz_parse_json_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_binary_protocol.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated_harness.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_binary_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_compact_protocol.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_compact_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_json_protocol.rb +0 -23
- data/test/fuzz/fuzz_roundtrip_json_protocol_harness.rb +0 -23
- data/test/fuzz/fuzz_tracer.rb +0 -29
data/spec/base_protocol_spec.rb
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
#
|
|
3
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
-
# or more contributor license agreements. See the NOTICE file
|
|
5
|
-
# distributed with this work for additional information
|
|
6
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
-
# to you under the Apache License, Version 2.0 (the
|
|
8
|
-
# "License"); you may not use this file except in compliance
|
|
9
|
-
# with the License. You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing,
|
|
14
|
-
# software distributed under the License is distributed on an
|
|
15
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
# KIND, either express or implied. See the License for the
|
|
17
|
-
# specific language governing permissions and limitations
|
|
18
|
-
# under the License.
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
require 'spec_helper'
|
|
22
|
-
|
|
23
|
-
describe 'BaseProtocol' do
|
|
24
|
-
before(:each) do
|
|
25
|
-
@trans = double("MockTransport")
|
|
26
|
-
@prot = Thrift::BaseProtocol.new(@trans)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
describe Thrift::BaseProtocol do
|
|
30
|
-
# most of the methods are stubs, so we can ignore them
|
|
31
|
-
|
|
32
|
-
it "should provide a reasonable to_s" do
|
|
33
|
-
expect(@trans).to receive(:to_s).once.and_return("trans")
|
|
34
|
-
expect(@prot.to_s).to eq("trans")
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "should make trans accessible" do
|
|
38
|
-
expect(@prot.trans).to eql(@trans)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'should write out a field nicely (deprecated write_field signature)' do
|
|
42
|
-
expect(@prot).to receive(:write_field_begin).with('field', 'type', 'fid').ordered
|
|
43
|
-
expect(@prot).to receive(:write_type).with({:name => 'field', :type => 'type'}, 'value').ordered
|
|
44
|
-
expect(@prot).to receive(:write_field_end).ordered
|
|
45
|
-
@prot.write_field('field', 'type', 'fid', 'value')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it 'should write out a field nicely' do
|
|
49
|
-
expect(@prot).to receive(:write_field_begin).with('field', 'type', 'fid').ordered
|
|
50
|
-
expect(@prot).to receive(:write_type).with({:name => 'field', :type => 'type', :binary => false}, 'value').ordered
|
|
51
|
-
expect(@prot).to receive(:write_field_end).ordered
|
|
52
|
-
@prot.write_field({:name => 'field', :type => 'type', :binary => false}, 'fid', 'value')
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it 'should write out the different types (deprecated write_type signature)' do
|
|
56
|
-
expect(@prot).to receive(:write_bool).with('bool').ordered
|
|
57
|
-
expect(@prot).to receive(:write_byte).with('byte').ordered
|
|
58
|
-
expect(@prot).to receive(:write_double).with('double').ordered
|
|
59
|
-
expect(@prot).to receive(:write_i16).with('i16').ordered
|
|
60
|
-
expect(@prot).to receive(:write_i32).with('i32').ordered
|
|
61
|
-
expect(@prot).to receive(:write_i64).with('i64').ordered
|
|
62
|
-
expect(@prot).to receive(:write_string).with('string').ordered
|
|
63
|
-
struct = double('Struct')
|
|
64
|
-
expect(struct).to receive(:write).with(@prot).ordered
|
|
65
|
-
@prot.write_type(Thrift::Types::BOOL, 'bool')
|
|
66
|
-
@prot.write_type(Thrift::Types::BYTE, 'byte')
|
|
67
|
-
@prot.write_type(Thrift::Types::DOUBLE, 'double')
|
|
68
|
-
@prot.write_type(Thrift::Types::I16, 'i16')
|
|
69
|
-
@prot.write_type(Thrift::Types::I32, 'i32')
|
|
70
|
-
@prot.write_type(Thrift::Types::I64, 'i64')
|
|
71
|
-
@prot.write_type(Thrift::Types::STRING, 'string')
|
|
72
|
-
@prot.write_type(Thrift::Types::STRUCT, struct)
|
|
73
|
-
# all other types are not implemented
|
|
74
|
-
[Thrift::Types::STOP, Thrift::Types::VOID, Thrift::Types::MAP, Thrift::Types::SET, Thrift::Types::LIST].each do |type|
|
|
75
|
-
expect { @prot.write_type(type, type.to_s) }.to raise_error(NotImplementedError)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
it 'should write out the different types' do
|
|
80
|
-
expect(@prot).to receive(:write_bool).with('bool').ordered
|
|
81
|
-
expect(@prot).to receive(:write_byte).with('byte').ordered
|
|
82
|
-
expect(@prot).to receive(:write_double).with('double').ordered
|
|
83
|
-
expect(@prot).to receive(:write_i16).with('i16').ordered
|
|
84
|
-
expect(@prot).to receive(:write_i32).with('i32').ordered
|
|
85
|
-
expect(@prot).to receive(:write_i64).with('i64').ordered
|
|
86
|
-
expect(@prot).to receive(:write_string).with('string').ordered
|
|
87
|
-
expect(@prot).to receive(:write_binary).with('binary').ordered
|
|
88
|
-
struct = double('Struct')
|
|
89
|
-
expect(struct).to receive(:write).with(@prot).ordered
|
|
90
|
-
@prot.write_type({:type => Thrift::Types::BOOL}, 'bool')
|
|
91
|
-
@prot.write_type({:type => Thrift::Types::BYTE}, 'byte')
|
|
92
|
-
@prot.write_type({:type => Thrift::Types::DOUBLE}, 'double')
|
|
93
|
-
@prot.write_type({:type => Thrift::Types::I16}, 'i16')
|
|
94
|
-
@prot.write_type({:type => Thrift::Types::I32}, 'i32')
|
|
95
|
-
@prot.write_type({:type => Thrift::Types::I64}, 'i64')
|
|
96
|
-
@prot.write_type({:type => Thrift::Types::STRING}, 'string')
|
|
97
|
-
@prot.write_type({:type => Thrift::Types::STRING, :binary => true}, 'binary')
|
|
98
|
-
@prot.write_type({:type => Thrift::Types::STRUCT}, struct)
|
|
99
|
-
# all other types are not implemented
|
|
100
|
-
[Thrift::Types::STOP, Thrift::Types::VOID, Thrift::Types::MAP, Thrift::Types::SET, Thrift::Types::LIST].each do |type|
|
|
101
|
-
expect { @prot.write_type({:type => type}, type.to_s) }.to raise_error(NotImplementedError)
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it 'should read the different types (deprecated read_type signature)' do
|
|
106
|
-
expect(@prot).to receive(:read_bool).ordered
|
|
107
|
-
expect(@prot).to receive(:read_byte).ordered
|
|
108
|
-
expect(@prot).to receive(:read_i16).ordered
|
|
109
|
-
expect(@prot).to receive(:read_i32).ordered
|
|
110
|
-
expect(@prot).to receive(:read_i64).ordered
|
|
111
|
-
expect(@prot).to receive(:read_double).ordered
|
|
112
|
-
expect(@prot).to receive(:read_string).ordered
|
|
113
|
-
@prot.read_type(Thrift::Types::BOOL)
|
|
114
|
-
@prot.read_type(Thrift::Types::BYTE)
|
|
115
|
-
@prot.read_type(Thrift::Types::I16)
|
|
116
|
-
@prot.read_type(Thrift::Types::I32)
|
|
117
|
-
@prot.read_type(Thrift::Types::I64)
|
|
118
|
-
@prot.read_type(Thrift::Types::DOUBLE)
|
|
119
|
-
@prot.read_type(Thrift::Types::STRING)
|
|
120
|
-
# all other types are not implemented
|
|
121
|
-
[Thrift::Types::STOP, Thrift::Types::VOID, Thrift::Types::MAP,
|
|
122
|
-
Thrift::Types::SET, Thrift::Types::LIST, Thrift::Types::STRUCT].each do |type|
|
|
123
|
-
expect { @prot.read_type(type) }.to raise_error(NotImplementedError)
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it 'should read the different types' do
|
|
128
|
-
expect(@prot).to receive(:read_bool).ordered
|
|
129
|
-
expect(@prot).to receive(:read_byte).ordered
|
|
130
|
-
expect(@prot).to receive(:read_i16).ordered
|
|
131
|
-
expect(@prot).to receive(:read_i32).ordered
|
|
132
|
-
expect(@prot).to receive(:read_i64).ordered
|
|
133
|
-
expect(@prot).to receive(:read_double).ordered
|
|
134
|
-
expect(@prot).to receive(:read_string).ordered
|
|
135
|
-
expect(@prot).to receive(:read_binary).ordered
|
|
136
|
-
@prot.read_type({:type => Thrift::Types::BOOL})
|
|
137
|
-
@prot.read_type({:type => Thrift::Types::BYTE})
|
|
138
|
-
@prot.read_type({:type => Thrift::Types::I16})
|
|
139
|
-
@prot.read_type({:type => Thrift::Types::I32})
|
|
140
|
-
@prot.read_type({:type => Thrift::Types::I64})
|
|
141
|
-
@prot.read_type({:type => Thrift::Types::DOUBLE})
|
|
142
|
-
@prot.read_type({:type => Thrift::Types::STRING})
|
|
143
|
-
@prot.read_type({:type => Thrift::Types::STRING, :binary => true})
|
|
144
|
-
# all other types are not implemented
|
|
145
|
-
[Thrift::Types::STOP, Thrift::Types::VOID, Thrift::Types::MAP,
|
|
146
|
-
Thrift::Types::SET, Thrift::Types::LIST, Thrift::Types::STRUCT].each do |type|
|
|
147
|
-
expect { @prot.read_type({:type => type}) }.to raise_error(NotImplementedError)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it "should skip the basic types" do
|
|
152
|
-
expect(@prot).to receive(:read_bool).ordered
|
|
153
|
-
expect(@prot).to receive(:read_byte).ordered
|
|
154
|
-
expect(@prot).to receive(:read_i16).ordered
|
|
155
|
-
expect(@prot).to receive(:read_i32).ordered
|
|
156
|
-
expect(@prot).to receive(:read_i64).ordered
|
|
157
|
-
expect(@prot).to receive(:read_double).ordered
|
|
158
|
-
expect(@prot).to receive(:read_string).ordered
|
|
159
|
-
@prot.skip(Thrift::Types::BOOL)
|
|
160
|
-
@prot.skip(Thrift::Types::BYTE)
|
|
161
|
-
@prot.skip(Thrift::Types::I16)
|
|
162
|
-
@prot.skip(Thrift::Types::I32)
|
|
163
|
-
@prot.skip(Thrift::Types::I64)
|
|
164
|
-
@prot.skip(Thrift::Types::DOUBLE)
|
|
165
|
-
@prot.skip(Thrift::Types::STRING)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it "should skip structs" do
|
|
169
|
-
real_skip = @prot.method(:skip)
|
|
170
|
-
expect(@prot).to receive(:read_struct_begin).ordered
|
|
171
|
-
expect(@prot).to receive(:read_field_begin).exactly(4).times.and_return(
|
|
172
|
-
['field 1', Thrift::Types::STRING, 1],
|
|
173
|
-
['field 2', Thrift::Types::I32, 2],
|
|
174
|
-
['field 3', Thrift::Types::MAP, 3],
|
|
175
|
-
[nil, Thrift::Types::STOP, 0]
|
|
176
|
-
)
|
|
177
|
-
expect(@prot).to receive(:read_field_end).exactly(3).times
|
|
178
|
-
expect(@prot).to receive(:read_string).exactly(3).times
|
|
179
|
-
expect(@prot).to receive(:read_i32).ordered
|
|
180
|
-
expect(@prot).to receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRING, 1])
|
|
181
|
-
# @prot.should_receive(:read_string).exactly(2).times
|
|
182
|
-
expect(@prot).to receive(:read_map_end).ordered
|
|
183
|
-
expect(@prot).to receive(:read_struct_end).ordered
|
|
184
|
-
real_skip.call(Thrift::Types::STRUCT)
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it "should skip maps" do
|
|
188
|
-
real_skip = @prot.method(:skip)
|
|
189
|
-
expect(@prot).to receive(:read_map_begin).ordered.and_return([Thrift::Types::STRING, Thrift::Types::STRUCT, 1])
|
|
190
|
-
expect(@prot).to receive(:read_string).ordered
|
|
191
|
-
expect(@prot).to receive(:read_struct_begin).ordered.and_return(["some_struct"])
|
|
192
|
-
expect(@prot).to receive(:read_field_begin).ordered.and_return([nil, Thrift::Types::STOP, nil]);
|
|
193
|
-
expect(@prot).to receive(:read_struct_end).ordered
|
|
194
|
-
expect(@prot).to receive(:read_map_end).ordered
|
|
195
|
-
real_skip.call(Thrift::Types::MAP)
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
it "should skip sets" do
|
|
199
|
-
real_skip = @prot.method(:skip)
|
|
200
|
-
expect(@prot).to receive(:read_set_begin).ordered.and_return([Thrift::Types::I64, 9])
|
|
201
|
-
expect(@prot).to receive(:read_i64).ordered.exactly(9).times
|
|
202
|
-
expect(@prot).to receive(:read_set_end)
|
|
203
|
-
real_skip.call(Thrift::Types::SET)
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it "should skip lists" do
|
|
207
|
-
real_skip = @prot.method(:skip)
|
|
208
|
-
expect(@prot).to receive(:read_list_begin).ordered.and_return([Thrift::Types::DOUBLE, 11])
|
|
209
|
-
expect(@prot).to receive(:read_double).ordered.exactly(11).times
|
|
210
|
-
expect(@prot).to receive(:read_list_end)
|
|
211
|
-
real_skip.call(Thrift::Types::LIST)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
it "should raise DEPTH_LIMIT when max_depth is exhausted" do
|
|
215
|
-
expect { @prot.skip(Thrift::Types::STRUCT, 0) }.to raise_error(Thrift::ProtocolException) do |e|
|
|
216
|
-
expect(e.type).to eq(Thrift::ProtocolException::DEPTH_LIMIT)
|
|
217
|
-
end
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
it "should skip at max_depth=1 without raising" do
|
|
221
|
-
expect(@prot).to receive(:read_bool).once
|
|
222
|
-
expect { @prot.skip(Thrift::Types::BOOL, 1) }.not_to raise_error
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
it "should reject negative container sizes while skipping" do
|
|
226
|
-
expect(@prot).to receive(:read_list_begin).and_return([Thrift::Types::I32, -1])
|
|
227
|
-
|
|
228
|
-
expect { @prot.skip(Thrift::Types::LIST) }.to raise_error(Thrift::ProtocolException, "Negative size") do |e|
|
|
229
|
-
expect(e.type).to eq(Thrift::ProtocolException::NEGATIVE_SIZE)
|
|
230
|
-
end
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
describe Thrift::BaseProtocolFactory do
|
|
235
|
-
it "should raise NotImplementedError" do
|
|
236
|
-
# returning nil since Protocol is just an abstract class
|
|
237
|
-
expect { Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport")) }.to raise_error(NotImplementedError)
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
it "should provide a reasonable to_s" do
|
|
241
|
-
expect(Thrift::BaseProtocolFactory.new.to_s).to eq("base")
|
|
242
|
-
end
|
|
243
|
-
end
|
|
244
|
-
end
|
data/spec/base_transport_spec.rb
DELETED
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
#
|
|
3
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
-
# or more contributor license agreements. See the NOTICE file
|
|
5
|
-
# distributed with this work for additional information
|
|
6
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
-
# to you under the Apache License, Version 2.0 (the
|
|
8
|
-
# "License"); you may not use this file except in compliance
|
|
9
|
-
# with the License. You may obtain a copy of the License at
|
|
10
|
-
#
|
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
#
|
|
13
|
-
# Unless required by applicable law or agreed to in writing,
|
|
14
|
-
# software distributed under the License is distributed on an
|
|
15
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
# KIND, either express or implied. See the License for the
|
|
17
|
-
# specific language governing permissions and limitations
|
|
18
|
-
# under the License.
|
|
19
|
-
#
|
|
20
|
-
|
|
21
|
-
require 'spec_helper'
|
|
22
|
-
|
|
23
|
-
describe 'BaseTransport' do
|
|
24
|
-
describe Thrift::TransportException do
|
|
25
|
-
it "should make type accessible" do
|
|
26
|
-
exc = Thrift::TransportException.new(Thrift::TransportException::ALREADY_OPEN, "msg")
|
|
27
|
-
expect(exc.type).to eq(Thrift::TransportException::ALREADY_OPEN)
|
|
28
|
-
expect(exc.message).to eq("msg")
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
describe Thrift::BaseTransport do
|
|
33
|
-
it "should read the specified size" do
|
|
34
|
-
transport = Thrift::BaseTransport.new
|
|
35
|
-
expect(transport).to receive(:read).with(40).ordered.and_return("10 letters")
|
|
36
|
-
expect(transport).to receive(:read).with(30).ordered.and_return("fifteen letters")
|
|
37
|
-
expect(transport).to receive(:read).with(15).ordered.and_return("more characters")
|
|
38
|
-
expect(transport.read_all(40)).to eq("10 lettersfifteen lettersmore characters")
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should coerce reads to binary encoding" do
|
|
42
|
-
transport = Thrift::BaseTransport.new
|
|
43
|
-
expect(transport).to receive(:read).with(3).and_return(+'abc')
|
|
44
|
-
|
|
45
|
-
buf = transport.read_all(3)
|
|
46
|
-
|
|
47
|
-
expect(buf).to eq('abc')
|
|
48
|
-
expect(buf.encoding).to eq(Encoding::BINARY)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should reject negative read sizes" do
|
|
52
|
-
transport = Thrift::BaseTransport.new
|
|
53
|
-
expect(transport).not_to receive(:read)
|
|
54
|
-
|
|
55
|
-
expect { transport.read_all(-1) }.to raise_error(Thrift::TransportException, "Negative size") do |e|
|
|
56
|
-
expect(e.type).to eq(Thrift::TransportException::NEGATIVE_SIZE)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "should stub out the rest of the methods" do
|
|
61
|
-
# can't test for stubbiness, so just make sure they're defined
|
|
62
|
-
[:open?, :open, :close, :read, :write, :flush].each do |sym|
|
|
63
|
-
expect(Thrift::BaseTransport.method_defined?(sym)).to be_truthy
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "should alias << to write" do
|
|
68
|
-
expect(Thrift::BaseTransport.instance_method(:<<)).to eq(Thrift::BaseTransport.instance_method(:write))
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "should provide a reasonable to_s" do
|
|
72
|
-
expect(Thrift::BaseTransport.new.to_s).to eq("base")
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
describe Thrift::BaseServerTransport do
|
|
77
|
-
it "should stub out its methods" do
|
|
78
|
-
[:listen, :accept, :close].each do |sym|
|
|
79
|
-
expect(Thrift::BaseServerTransport.method_defined?(sym)).to be_truthy
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe Thrift::BaseTransportFactory do
|
|
85
|
-
it "should return the transport it's given" do
|
|
86
|
-
transport = double("Transport")
|
|
87
|
-
expect(Thrift::BaseTransportFactory.new.get_transport(transport)).to eql(transport)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "should provide a reasonable to_s" do
|
|
91
|
-
expect(Thrift::BaseTransportFactory.new.to_s).to eq("base")
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
describe Thrift::BufferedTransport do
|
|
96
|
-
it "should provide a to_s that describes the encapsulation" do
|
|
97
|
-
trans = double("Transport")
|
|
98
|
-
expect(trans).to receive(:to_s).and_return("mock")
|
|
99
|
-
expect(Thrift::BufferedTransport.new(trans).to_s).to eq("buffered(mock)")
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it "should pass through everything but write/flush/read" do
|
|
103
|
-
trans = double("Transport")
|
|
104
|
-
expect(trans).to receive(:open?).ordered.and_return("+ open?")
|
|
105
|
-
expect(trans).to receive(:open).ordered.and_return("+ open")
|
|
106
|
-
expect(trans).to receive(:flush).ordered # from the close
|
|
107
|
-
expect(trans).to receive(:close).ordered.and_return("+ close")
|
|
108
|
-
btrans = Thrift::BufferedTransport.new(trans)
|
|
109
|
-
expect(btrans.open?).to eq("+ open?")
|
|
110
|
-
expect(btrans.open).to eq("+ open")
|
|
111
|
-
expect(btrans.close).to eq("+ close")
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
it "should buffer reads in chunks of #{Thrift::BufferedTransport::DEFAULT_BUFFER}" do
|
|
115
|
-
trans = double("Transport")
|
|
116
|
-
expect(trans).to receive(:read).with(Thrift::BufferedTransport::DEFAULT_BUFFER).and_return("lorum ipsum dolor emet")
|
|
117
|
-
btrans = Thrift::BufferedTransport.new(trans)
|
|
118
|
-
expect(btrans.read(6)).to eq("lorum ")
|
|
119
|
-
expect(btrans.read(6)).to eq("ipsum ")
|
|
120
|
-
expect(btrans.read(6)).to eq("dolor ")
|
|
121
|
-
expect(btrans.read(6)).to eq("emet")
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
it "should buffer writes and send them on flush" do
|
|
125
|
-
trans = double("Transport")
|
|
126
|
-
btrans = Thrift::BufferedTransport.new(trans)
|
|
127
|
-
btrans.write("one/")
|
|
128
|
-
btrans.write("two/")
|
|
129
|
-
btrans.write("three/")
|
|
130
|
-
expect(trans).to receive(:write).with("one/two/three/").ordered
|
|
131
|
-
expect(trans).to receive(:flush).ordered
|
|
132
|
-
btrans.flush
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it "should only send buffered data once" do
|
|
136
|
-
trans = double("Transport")
|
|
137
|
-
btrans = Thrift::BufferedTransport.new(trans)
|
|
138
|
-
btrans.write("one/")
|
|
139
|
-
btrans.write("two/")
|
|
140
|
-
btrans.write("three/")
|
|
141
|
-
expect(trans).to receive(:write).with("one/two/three/")
|
|
142
|
-
allow(trans).to receive(:flush)
|
|
143
|
-
btrans.flush
|
|
144
|
-
# Nothing to flush with no data
|
|
145
|
-
btrans.flush
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
it "should flush on close" do
|
|
149
|
-
trans = double("Transport")
|
|
150
|
-
expect(trans).to receive(:close)
|
|
151
|
-
btrans = Thrift::BufferedTransport.new(trans)
|
|
152
|
-
expect(btrans).to receive(:flush)
|
|
153
|
-
btrans.close
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it "should not write to socket if there's no data" do
|
|
157
|
-
trans = double("Transport")
|
|
158
|
-
expect(trans).to receive(:flush)
|
|
159
|
-
btrans = Thrift::BufferedTransport.new(trans)
|
|
160
|
-
btrans.flush
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
describe Thrift::BufferedTransportFactory do
|
|
165
|
-
it "should wrap the given transport in a BufferedTransport" do
|
|
166
|
-
trans = double("Transport")
|
|
167
|
-
btrans = double("BufferedTransport")
|
|
168
|
-
expect(Thrift::BufferedTransport).to receive(:new).with(trans).and_return(btrans)
|
|
169
|
-
expect(Thrift::BufferedTransportFactory.new.get_transport(trans)).to eq(btrans)
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
it "should provide a reasonable to_s" do
|
|
173
|
-
expect(Thrift::BufferedTransportFactory.new.to_s).to eq("buffered")
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
describe Thrift::FramedTransport do
|
|
178
|
-
before(:each) do
|
|
179
|
-
@trans = double("Transport")
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
it "should provide a to_s that describes the encapsulation" do
|
|
183
|
-
trans = double("Transport")
|
|
184
|
-
expect(trans).to receive(:to_s).and_return("mock")
|
|
185
|
-
expect(Thrift::FramedTransport.new(trans).to_s).to eq("framed(mock)")
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
it "should pass through open?/open/close" do
|
|
189
|
-
ftrans = Thrift::FramedTransport.new(@trans)
|
|
190
|
-
expect(@trans).to receive(:open?).ordered.and_return("+ open?")
|
|
191
|
-
expect(@trans).to receive(:open).ordered.and_return("+ open")
|
|
192
|
-
expect(@trans).to receive(:close).ordered.and_return("+ close")
|
|
193
|
-
expect(ftrans.open?).to eq("+ open?")
|
|
194
|
-
expect(ftrans.open).to eq("+ open")
|
|
195
|
-
expect(ftrans.close).to eq("+ close")
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
it "should pass through read when read is turned off" do
|
|
199
|
-
ftrans = Thrift::FramedTransport.new(@trans, false, true)
|
|
200
|
-
expect(@trans).to receive(:read).with(17).ordered.and_return("+ read")
|
|
201
|
-
expect(ftrans.read(17)).to eq("+ read")
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
it "should pass through write/flush when write is turned off" do
|
|
205
|
-
ftrans = Thrift::FramedTransport.new(@trans, true, false)
|
|
206
|
-
expect(@trans).to receive(:write).with("foo").ordered.and_return("+ write")
|
|
207
|
-
expect(@trans).to receive(:flush).ordered.and_return("+ flush")
|
|
208
|
-
expect(ftrans.write("foo")).to eq("+ write")
|
|
209
|
-
expect(ftrans.flush).to eq("+ flush")
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
it "should return a full frame if asked for >= the frame's length" do
|
|
213
|
-
frame = "this is a frame"
|
|
214
|
-
expect(@trans).to receive(:read_all).with(4).and_return("\000\000\000\017")
|
|
215
|
-
expect(@trans).to receive(:read_all).with(frame.length).and_return(frame)
|
|
216
|
-
expect(Thrift::FramedTransport.new(@trans).read(frame.length + 10)).to eq(frame)
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
it "should return slices of the frame when asked for < the frame's length" do
|
|
220
|
-
frame = "this is a frame"
|
|
221
|
-
expect(@trans).to receive(:read_all).with(4).and_return("\000\000\000\017")
|
|
222
|
-
expect(@trans).to receive(:read_all).with(frame.length).and_return(frame)
|
|
223
|
-
ftrans = Thrift::FramedTransport.new(@trans)
|
|
224
|
-
expect(ftrans.read(4)).to eq("this")
|
|
225
|
-
expect(ftrans.read(4)).to eq(" is ")
|
|
226
|
-
expect(ftrans.read(16)).to eq("a frame")
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
it "should return nothing if asked for <= 0" do
|
|
230
|
-
expect(Thrift::FramedTransport.new(@trans).read(-2)).to eq("")
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
it "should pull a new frame when the first is exhausted" do
|
|
234
|
-
frame = "this is a frame"
|
|
235
|
-
frame2 = "yet another frame"
|
|
236
|
-
expect(@trans).to receive(:read_all).with(4).and_return("\000\000\000\017", "\000\000\000\021")
|
|
237
|
-
expect(@trans).to receive(:read_all).with(frame.length).and_return(frame)
|
|
238
|
-
expect(@trans).to receive(:read_all).with(frame2.length).and_return(frame2)
|
|
239
|
-
ftrans = Thrift::FramedTransport.new(@trans)
|
|
240
|
-
expect(ftrans.read(4)).to eq("this")
|
|
241
|
-
expect(ftrans.read(8)).to eq(" is a fr")
|
|
242
|
-
expect(ftrans.read(6)).to eq("ame")
|
|
243
|
-
expect(ftrans.read(4)).to eq("yet ")
|
|
244
|
-
expect(ftrans.read(16)).to eq("another frame")
|
|
245
|
-
end
|
|
246
|
-
|
|
247
|
-
it "should buffer writes" do
|
|
248
|
-
ftrans = Thrift::FramedTransport.new(@trans)
|
|
249
|
-
expect(@trans).not_to receive(:write)
|
|
250
|
-
ftrans.write("foo")
|
|
251
|
-
ftrans.write("bar")
|
|
252
|
-
ftrans.write("this is a frame")
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
it "should write slices of the buffer" do
|
|
256
|
-
ftrans = Thrift::FramedTransport.new(@trans)
|
|
257
|
-
ftrans.write("foobar", 3)
|
|
258
|
-
ftrans.write("barfoo", 1)
|
|
259
|
-
allow(@trans).to receive(:flush)
|
|
260
|
-
expect(@trans).to receive(:write).with("\000\000\000\004foob")
|
|
261
|
-
ftrans.flush
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
it "should flush frames with a 4-byte header" do
|
|
265
|
-
ftrans = Thrift::FramedTransport.new(@trans)
|
|
266
|
-
expect(@trans).to receive(:write).with("\000\000\000\035one/two/three/this is a frame").ordered
|
|
267
|
-
expect(@trans).to receive(:flush).ordered
|
|
268
|
-
ftrans.write("one/")
|
|
269
|
-
ftrans.write("two/")
|
|
270
|
-
ftrans.write("three/")
|
|
271
|
-
ftrans.write("this is a frame")
|
|
272
|
-
ftrans.flush
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
it "should not flush the same buffered data twice" do
|
|
276
|
-
ftrans = Thrift::FramedTransport.new(@trans)
|
|
277
|
-
expect(@trans).to receive(:write).with("\000\000\000\007foo/bar")
|
|
278
|
-
allow(@trans).to receive(:flush)
|
|
279
|
-
ftrans.write("foo")
|
|
280
|
-
ftrans.write("/bar")
|
|
281
|
-
ftrans.flush
|
|
282
|
-
expect(@trans).to receive(:write).with("\000\000\000\000")
|
|
283
|
-
ftrans.flush
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
describe Thrift::FramedTransportFactory do
|
|
288
|
-
it "should wrap the given transport in a FramedTransport" do
|
|
289
|
-
trans = double("Transport")
|
|
290
|
-
expect(Thrift::FramedTransport).to receive(:new).with(trans)
|
|
291
|
-
Thrift::FramedTransportFactory.new.get_transport(trans)
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
it "should provide a reasonable to_s" do
|
|
295
|
-
expect(Thrift::FramedTransportFactory.new.to_s).to eq("framed")
|
|
296
|
-
end
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
describe Thrift::MemoryBufferTransport do
|
|
300
|
-
before(:each) do
|
|
301
|
-
@buffer = Thrift::MemoryBufferTransport.new
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
it "should provide a reasonable to_s" do
|
|
305
|
-
expect(@buffer.to_s).to eq("memory")
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
it "should accept a buffer on input and use it directly" do
|
|
309
|
-
s = +"this is a test"
|
|
310
|
-
@buffer = Thrift::MemoryBufferTransport.new(s)
|
|
311
|
-
expect(@buffer.read(4)).to eq("this")
|
|
312
|
-
s.slice!(-4..-1)
|
|
313
|
-
expect(@buffer.read(@buffer.available)).to eq(" is a ")
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
it "should always remain open" do
|
|
317
|
-
expect(@buffer).to be_open
|
|
318
|
-
@buffer.close
|
|
319
|
-
expect(@buffer).to be_open
|
|
320
|
-
end
|
|
321
|
-
|
|
322
|
-
it "should respond to peek and available" do
|
|
323
|
-
@buffer.write "some data"
|
|
324
|
-
expect(@buffer.peek).to be_truthy
|
|
325
|
-
expect(@buffer.available).to eq(9)
|
|
326
|
-
@buffer.read(4)
|
|
327
|
-
expect(@buffer.peek).to be_truthy
|
|
328
|
-
expect(@buffer.available).to eq(5)
|
|
329
|
-
@buffer.read(5)
|
|
330
|
-
expect(@buffer.peek).to be_falsey
|
|
331
|
-
expect(@buffer.available).to eq(0)
|
|
332
|
-
end
|
|
333
|
-
|
|
334
|
-
it "should be able to reset the buffer" do
|
|
335
|
-
@buffer.write "test data"
|
|
336
|
-
@buffer.reset_buffer("foobar")
|
|
337
|
-
expect(@buffer.available).to eq(6)
|
|
338
|
-
expect(@buffer.read(@buffer.available)).to eq("foobar")
|
|
339
|
-
@buffer.reset_buffer
|
|
340
|
-
expect(@buffer.available).to eq(0)
|
|
341
|
-
end
|
|
342
|
-
|
|
343
|
-
it "should copy the given string when resetting the buffer" do
|
|
344
|
-
s = "this is a test"
|
|
345
|
-
@buffer.reset_buffer(s)
|
|
346
|
-
expect(@buffer.available).to eq(14)
|
|
347
|
-
@buffer.read(10)
|
|
348
|
-
expect(@buffer.available).to eq(4)
|
|
349
|
-
expect(s).to eq("this is a test")
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
it "should return from read what was given in write" do
|
|
353
|
-
@buffer.write "test data"
|
|
354
|
-
expect(@buffer.read(4)).to eq("test")
|
|
355
|
-
expect(@buffer.read(@buffer.available)).to eq(" data")
|
|
356
|
-
@buffer.write "foo"
|
|
357
|
-
@buffer.write " bar"
|
|
358
|
-
expect(@buffer.read(@buffer.available)).to eq("foo bar")
|
|
359
|
-
end
|
|
360
|
-
|
|
361
|
-
it "should force mutable write buffers into binary in place" do
|
|
362
|
-
s = "abc \u20AC".encode("UTF-8")
|
|
363
|
-
@buffer.write(s)
|
|
364
|
-
expect(s.encoding).to eq(Encoding::BINARY)
|
|
365
|
-
expect(@buffer.read(@buffer.available)).to eq("abc \u20AC".encode("UTF-8").b)
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
it "should not mutate frozen write buffers while forcing binary encoding" do
|
|
369
|
-
s = "abc \u20AC".encode("UTF-8").freeze
|
|
370
|
-
@buffer.write(s)
|
|
371
|
-
expect(s.encoding).to eq(Encoding::UTF_8)
|
|
372
|
-
expect(s).to be_frozen
|
|
373
|
-
expect(@buffer.read(@buffer.available)).to eq("abc \u20AC".encode("UTF-8").b)
|
|
374
|
-
end
|
|
375
|
-
|
|
376
|
-
it "should throw an EOFError when there isn't enough data in the buffer" do
|
|
377
|
-
@buffer.reset_buffer("")
|
|
378
|
-
expect{ @buffer.read(1) }.to raise_error(EOFError)
|
|
379
|
-
|
|
380
|
-
@buffer.reset_buffer("1234")
|
|
381
|
-
expect{ @buffer.read(5) }.to raise_error(EOFError)
|
|
382
|
-
end
|
|
383
|
-
|
|
384
|
-
it "should reject negative read_all sizes" do
|
|
385
|
-
expect { @buffer.read_all(-1) }.to raise_error(Thrift::TransportException, "Negative size") do |e|
|
|
386
|
-
expect(e.type).to eq(Thrift::TransportException::NEGATIVE_SIZE)
|
|
387
|
-
end
|
|
388
|
-
end
|
|
389
|
-
end
|
|
390
|
-
|
|
391
|
-
describe Thrift::IOStreamTransport do
|
|
392
|
-
before(:each) do
|
|
393
|
-
@input = double("Input", :closed? => false)
|
|
394
|
-
@output = double("Output", :closed? => false)
|
|
395
|
-
@trans = Thrift::IOStreamTransport.new(@input, @output)
|
|
396
|
-
end
|
|
397
|
-
|
|
398
|
-
it "should provide a reasonable to_s" do
|
|
399
|
-
expect(@input).to receive(:to_s).and_return("mock_input")
|
|
400
|
-
expect(@output).to receive(:to_s).and_return("mock_output")
|
|
401
|
-
expect(@trans.to_s).to eq("iostream(input=mock_input,output=mock_output)")
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
it "should be open as long as both input or output are open" do
|
|
405
|
-
expect(@trans).to be_open
|
|
406
|
-
allow(@input).to receive(:closed?).and_return(true)
|
|
407
|
-
expect(@trans).to be_open
|
|
408
|
-
allow(@input).to receive(:closed?).and_return(false)
|
|
409
|
-
allow(@output).to receive(:closed?).and_return(true)
|
|
410
|
-
expect(@trans).to be_open
|
|
411
|
-
allow(@input).to receive(:closed?).and_return(true)
|
|
412
|
-
expect(@trans).not_to be_open
|
|
413
|
-
end
|
|
414
|
-
|
|
415
|
-
it "should pass through read/write to input/output" do
|
|
416
|
-
expect(@input).to receive(:read).with(17).and_return("+ read")
|
|
417
|
-
expect(@output).to receive(:write).with("foobar").and_return("+ write")
|
|
418
|
-
expect(@trans.read(17)).to eq("+ read")
|
|
419
|
-
expect(@trans.write("foobar")).to eq("+ write")
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
it "should close both input and output when closed" do
|
|
423
|
-
expect(@input).to receive(:close)
|
|
424
|
-
expect(@output).to receive(:close)
|
|
425
|
-
@trans.close
|
|
426
|
-
end
|
|
427
|
-
end
|
|
428
|
-
end
|