thrift 0.23.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 +203 -40
- data/ext/binary_protocol_accelerated.c +130 -40
- data/ext/bytes.c +14 -0
- data/ext/compact_protocol.c +184 -91
- data/ext/constants.h +3 -0
- data/ext/extconf.rb +12 -4
- data/ext/macros.h +11 -0
- data/ext/memory_buffer.c +67 -12
- data/ext/struct.c +192 -71
- data/ext/thrift_native.c +7 -0
- data/lib/thrift/bytes.rb +6 -3
- data/lib/thrift/client.rb +31 -33
- data/lib/thrift/exceptions.rb +11 -8
- data/lib/thrift/multiplexed_processor.rb +17 -8
- data/lib/thrift/processor.rb +25 -3
- data/lib/thrift/protocol/base_protocol.rb +66 -31
- data/lib/thrift/protocol/binary_protocol.rb +80 -37
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +7 -2
- data/lib/thrift/protocol/compact_protocol.rb +204 -88
- data/lib/thrift/protocol/header_protocol.rb +15 -3
- data/lib/thrift/protocol/json_protocol.rb +158 -109
- data/lib/thrift/protocol/multiplexed_protocol.rb +3 -3
- data/lib/thrift/protocol/protocol_decorator.rb +6 -2
- data/lib/thrift/serializer/deserializer.rb +1 -0
- data/lib/thrift/serializer/serializer.rb +7 -0
- data/lib/thrift/server/base_server.rb +11 -2
- data/lib/thrift/server/nonblocking_server.rb +69 -20
- data/lib/thrift/server/rack_application.rb +69 -0
- data/lib/thrift/server/simple_server.rb +27 -15
- data/lib/thrift/server/thin_http_server.rb +21 -44
- data/lib/thrift/server/thread_pool_server.rb +21 -17
- data/lib/thrift/server/threaded_server.rb +22 -18
- data/lib/thrift/struct.rb +34 -18
- data/lib/thrift/struct_union.rb +37 -36
- data/lib/thrift/thrift_native.rb +2 -1
- data/lib/thrift/transport/base_server_transport.rb +3 -0
- data/lib/thrift/transport/base_transport.rb +26 -4
- data/lib/thrift/transport/buffered_transport.rb +5 -4
- data/lib/thrift/transport/framed_transport.rb +33 -7
- data/lib/thrift/transport/header_transport.rb +159 -33
- data/lib/thrift/transport/http_client_transport.rb +28 -14
- data/lib/thrift/transport/io_stream_transport.rb +3 -1
- data/lib/thrift/transport/memory_buffer_transport.rb +14 -9
- data/lib/thrift/transport/server_socket.rb +10 -8
- data/lib/thrift/transport/socket.rb +85 -48
- data/lib/thrift/transport/ssl_server_socket.rb +67 -6
- data/lib/thrift/transport/ssl_socket.rb +73 -14
- data/lib/thrift/transport/unix_server_socket.rb +6 -2
- data/lib/thrift/transport/unix_socket.rb +5 -6
- data/lib/thrift/types.rb +23 -22
- data/lib/thrift/union.rb +21 -11
- data/lib/thrift/uuid.rb +9 -8
- data/lib/thrift.rb +40 -39
- metadata +7 -266
- data/benchmark/Benchmark.thrift +0 -24
- data/benchmark/benchmark.rb +0 -285
- data/benchmark/client.rb +0 -117
- data/benchmark/server.rb +0 -120
- data/benchmark/thin_server.rb +0 -45
- data/lib/thrift/server/mongrel_http_server.rb +0 -60
- 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 -187
- data/spec/base_protocol_spec.rb +0 -224
- data/spec/base_transport_spec.rb +0 -387
- data/spec/binary_protocol_accelerated_spec.rb +0 -46
- data/spec/binary_protocol_spec.rb +0 -72
- data/spec/binary_protocol_spec_shared.rb +0 -445
- data/spec/bytes_spec.rb +0 -99
- data/spec/client_spec.rb +0 -166
- data/spec/compact_protocol_spec.rb +0 -196
- data/spec/constants_demo_spec.rb +0 -101
- data/spec/exception_spec.rb +0 -140
- data/spec/flat_spec.rb +0 -62
- data/spec/header_protocol_spec.rb +0 -475
- data/spec/header_transport_spec.rb +0 -386
- data/spec/http_client_spec.rb +0 -159
- data/spec/json_protocol_spec.rb +0 -552
- data/spec/namespaced_spec.rb +0 -66
- data/spec/nonblocking_server_spec.rb +0 -361
- data/spec/processor_spec.rb +0 -79
- data/spec/serializer_spec.rb +0 -66
- data/spec/server_socket_spec.rb +0 -84
- data/spec/server_spec.rb +0 -186
- data/spec/socket_spec.rb +0 -67
- data/spec/socket_spec_shared.rb +0 -167
- data/spec/spec_helper.rb +0 -69
- data/spec/ssl_server_socket_spec.rb +0 -45
- data/spec/ssl_socket_spec.rb +0 -87
- data/spec/struct_nested_containers_spec.rb +0 -190
- data/spec/struct_spec.rb +0 -397
- data/spec/support/header_protocol_helper.rb +0 -54
- data/spec/thin_http_server_spec.rb +0 -126
- data/spec/types_spec.rb +0 -117
- data/spec/union_spec.rb +0 -272
- data/spec/unix_socket_spec.rb +0 -115
- data/spec/uuid_validation_spec.rb +0 -238
- data/test/fuzz/Makefile.am +0 -173
- data/test/fuzz/README.md +0 -149
- data/test/fuzz/fuzz_common.rb +0 -95
- data/test/fuzz/fuzz_parse_binary_protocol.rb +0 -22
- data/test/fuzz/fuzz_parse_binary_protocol_accelerated.rb +0 -22
- data/test/fuzz/fuzz_parse_binary_protocol_accelerated_harness.rb +0 -22
- data/test/fuzz/fuzz_parse_binary_protocol_harness.rb +0 -22
- data/test/fuzz/fuzz_parse_compact_protocol.rb +0 -22
- data/test/fuzz/fuzz_parse_compact_protocol_harness.rb +0 -22
- data/test/fuzz/fuzz_parse_json_protocol.rb +0 -22
- data/test/fuzz/fuzz_parse_json_protocol_harness.rb +0 -22
- data/test/fuzz/fuzz_roundtrip_binary_protocol.rb +0 -22
- data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated.rb +0 -22
- data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated_harness.rb +0 -22
- data/test/fuzz/fuzz_roundtrip_binary_protocol_harness.rb +0 -22
- data/test/fuzz/fuzz_roundtrip_compact_protocol.rb +0 -22
- data/test/fuzz/fuzz_roundtrip_compact_protocol_harness.rb +0 -22
- data/test/fuzz/fuzz_roundtrip_json_protocol.rb +0 -22
- data/test/fuzz/fuzz_roundtrip_json_protocol_harness.rb +0 -22
- data/test/fuzz/fuzz_tracer.rb +0 -28
data/spec/client_spec.rb
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
|
4
|
-
# distributed with this work for additional information
|
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
|
7
|
-
# "License"); you may not use this file except in compliance
|
|
8
|
-
# with the License. You may obtain a copy of the License at
|
|
9
|
-
#
|
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
|
13
|
-
# software distributed under the License is distributed on an
|
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
# KIND, either express or implied. See the License for the
|
|
16
|
-
# specific language governing permissions and limitations
|
|
17
|
-
# under the License.
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
require 'spec_helper'
|
|
21
|
-
|
|
22
|
-
describe 'Client' do
|
|
23
|
-
class ClientSpec
|
|
24
|
-
include Thrift::Client
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
class EmptyArgs
|
|
28
|
-
def write(_prot)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
before(:each) do
|
|
33
|
-
@prot = double("MockProtocol")
|
|
34
|
-
@client = ClientSpec.new(@prot)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe Thrift::Client do
|
|
38
|
-
it "should re-use iprot for oprot if not otherwise specified" do
|
|
39
|
-
expect(@client.instance_variable_get(:'@iprot')).to eql(@prot)
|
|
40
|
-
expect(@client.instance_variable_get(:'@oprot')).to eql(@prot)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should send a test message" do
|
|
44
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 0)
|
|
45
|
-
mock_args = double('#<TestMessage_args:mock>')
|
|
46
|
-
expect(mock_args).to receive(:foo=).with('foo')
|
|
47
|
-
expect(mock_args).to receive(:bar=).with(42)
|
|
48
|
-
expect(mock_args).to receive(:write).with(@prot)
|
|
49
|
-
expect(@prot).to receive(:write_message_end)
|
|
50
|
-
expect(@prot).to receive(:trans) do
|
|
51
|
-
double('trans').tap do |trans|
|
|
52
|
-
expect(trans).to receive(:flush)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
klass = double("TestMessage_args", :new => mock_args)
|
|
56
|
-
@client.send_message('testMessage', klass, :foo => 'foo', :bar => 42)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "should increment the sequence id when sending messages" do
|
|
60
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 0).ordered
|
|
61
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage2', Thrift::MessageTypes::CALL, 1).ordered
|
|
62
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage3', Thrift::MessageTypes::CALL, 2).ordered
|
|
63
|
-
allow(@prot).to receive(:write_message_end)
|
|
64
|
-
allow(@prot).to receive(:trans).and_return(double("trans", :flush => nil))
|
|
65
|
-
|
|
66
|
-
args_class = double("ArgsClass", :new => EmptyArgs.new)
|
|
67
|
-
@client.send_message('testMessage', args_class)
|
|
68
|
-
@client.send_message('testMessage2', args_class)
|
|
69
|
-
@client.send_message('testMessage3', args_class)
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "should keep pending reply sequence ids in FIFO order" do
|
|
73
|
-
expect(@prot).to receive(:write_message_begin).with('first', Thrift::MessageTypes::CALL, 0).ordered
|
|
74
|
-
expect(@prot).to receive(:write_message_begin).with('second', Thrift::MessageTypes::CALL, 1).ordered
|
|
75
|
-
allow(@prot).to receive(:write_message_end)
|
|
76
|
-
allow(@prot).to receive(:trans).and_return(double("trans", :flush => nil))
|
|
77
|
-
|
|
78
|
-
args_class = double("ArgsClass", :new => EmptyArgs.new)
|
|
79
|
-
@client.send_message('first', args_class)
|
|
80
|
-
@client.send_message('second', args_class)
|
|
81
|
-
|
|
82
|
-
expect {
|
|
83
|
-
@client.validate_message_begin('first', Thrift::MessageTypes::REPLY, 0, 'first')
|
|
84
|
-
}.not_to raise_error
|
|
85
|
-
expect {
|
|
86
|
-
@client.validate_message_begin('second', Thrift::MessageTypes::REPLY, 1, 'second')
|
|
87
|
-
}.not_to raise_error
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "should receive a test message" do
|
|
91
|
-
expect(@prot).to receive(:read_message_begin).and_return [nil, Thrift::MessageTypes::CALL, 0]
|
|
92
|
-
expect(@prot).to receive(:read_message_end)
|
|
93
|
-
mock_klass = double("#<MockClass:mock>")
|
|
94
|
-
expect(mock_klass).to receive(:read).with(@prot)
|
|
95
|
-
@client.receive_message_begin()
|
|
96
|
-
@client.receive_message(double("MockClass", :new => mock_klass))
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it "should raise BAD_SEQUENCE_ID for mismatched replies" do
|
|
100
|
-
@client.instance_variable_set(:@pending_seqids, [0])
|
|
101
|
-
|
|
102
|
-
expect {
|
|
103
|
-
@client.validate_message_begin('testMessage', Thrift::MessageTypes::REPLY, 1, 'testMessage')
|
|
104
|
-
}.to raise_error(Thrift::ApplicationException) { |error|
|
|
105
|
-
expect(error.type).to eq(Thrift::ApplicationException::BAD_SEQUENCE_ID)
|
|
106
|
-
}
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
it "should raise WRONG_METHOD_NAME for unexpected replies" do
|
|
110
|
-
@client.instance_variable_set(:@pending_seqids, [0])
|
|
111
|
-
|
|
112
|
-
expect {
|
|
113
|
-
@client.validate_message_begin('otherMessage', Thrift::MessageTypes::REPLY, 0, 'testMessage')
|
|
114
|
-
}.to raise_error(Thrift::ApplicationException) { |error|
|
|
115
|
-
expect(error.type).to eq(Thrift::ApplicationException::WRONG_METHOD_NAME)
|
|
116
|
-
}
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "should raise INVALID_MESSAGE_TYPE for non-reply messages" do
|
|
120
|
-
@client.instance_variable_set(:@pending_seqids, [0])
|
|
121
|
-
|
|
122
|
-
expect {
|
|
123
|
-
@client.validate_message_begin('testMessage', Thrift::MessageTypes::CALL, 0, 'testMessage')
|
|
124
|
-
}.to raise_error(Thrift::ApplicationException) { |error|
|
|
125
|
-
expect(error.type).to eq(Thrift::ApplicationException::INVALID_MESSAGE_TYPE)
|
|
126
|
-
}
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
it "should raise received application exceptions" do
|
|
130
|
-
expect(@prot).to receive(:read_message_end)
|
|
131
|
-
server_exception = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN, "boom")
|
|
132
|
-
expect(server_exception).to receive(:read).with(@prot)
|
|
133
|
-
expect(Thrift::ApplicationException).to receive(:new).and_return(server_exception)
|
|
134
|
-
@client.instance_variable_set(:@pending_seqids, [0])
|
|
135
|
-
|
|
136
|
-
expect {
|
|
137
|
-
@client.validate_message_begin('testMessage', Thrift::MessageTypes::EXCEPTION, 0, 'testMessage')
|
|
138
|
-
}.to raise_error(Thrift::ApplicationException, "boom")
|
|
139
|
-
expect(@client.instance_variable_get(:@pending_seqids)).to be_empty
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "should roll sequence ids across the signed int32 boundary" do
|
|
143
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, Thrift::Client::MAX_SEQUENCE_ID).ordered
|
|
144
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage2', Thrift::MessageTypes::CALL, Thrift::Client::MIN_SEQUENCE_ID).ordered
|
|
145
|
-
allow(@prot).to receive(:write_message_end)
|
|
146
|
-
allow(@prot).to receive(:trans).and_return(double("trans", :flush => nil))
|
|
147
|
-
|
|
148
|
-
@client.instance_variable_set(:@seqid, Thrift::Client::MAX_SEQUENCE_ID)
|
|
149
|
-
args_class = double("ArgsClass", :new => EmptyArgs.new)
|
|
150
|
-
@client.send_message('testMessage', args_class)
|
|
151
|
-
@client.send_message('testMessage2', args_class)
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it "should close the transport if an error occurs while sending a message" do
|
|
155
|
-
allow(@prot).to receive(:write_message_begin)
|
|
156
|
-
expect(@prot).not_to receive(:write_message_end)
|
|
157
|
-
mock_args = double("#<TestMessage_args:mock>")
|
|
158
|
-
expect(mock_args).to receive(:write).with(@prot).and_raise(StandardError)
|
|
159
|
-
trans = double("MockTransport")
|
|
160
|
-
allow(@prot).to receive(:trans).and_return(trans)
|
|
161
|
-
expect(trans).to receive(:close)
|
|
162
|
-
klass = double("TestMessage_args", :new => mock_args)
|
|
163
|
-
expect { @client.send_message("testMessage", klass) }.to raise_error(StandardError)
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
end
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
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 Thrift::CompactProtocol do
|
|
24
|
-
TESTS = {
|
|
25
|
-
:byte => (-127..127).to_a,
|
|
26
|
-
:i16 => (0..14).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
|
|
27
|
-
:i32 => (0..30).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
|
|
28
|
-
:i64 => (0..62).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
|
|
29
|
-
:string => ["", "1", "short", "fourteen123456", "fifteen12345678", "unicode characters: \u20AC \u20AD", "1" * 127, "1" * 3000],
|
|
30
|
-
:binary => ["", "\001", "\001" * 5, "\001" * 14, "\001" * 15, "\001" * 127, "\001" * 3000],
|
|
31
|
-
:double => [0.0, 1.0, -1.0, 1.1, -1.1, 10000000.1, 1.0/0.0, -1.0/0.0],
|
|
32
|
-
:bool => [true, false]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
it "should encode and decode naked primitives correctly" do
|
|
36
|
-
TESTS.each_pair do |primitive_type, test_values|
|
|
37
|
-
test_values.each do |value|
|
|
38
|
-
# puts "testing #{value}" if primitive_type == :i64
|
|
39
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
40
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
41
|
-
|
|
42
|
-
proto.send(writer(primitive_type), value)
|
|
43
|
-
# puts "buf: #{trans.inspect_buffer}" if primitive_type == :i64
|
|
44
|
-
read_back = proto.send(reader(primitive_type))
|
|
45
|
-
expect(read_back).to eq(value)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
it "should encode and decode primitives in fields correctly" do
|
|
51
|
-
TESTS.each_pair do |primitive_type, test_values|
|
|
52
|
-
final_primitive_type = primitive_type == :binary ? :string : primitive_type
|
|
53
|
-
thrift_type = Thrift::Types.const_get(final_primitive_type.to_s.upcase)
|
|
54
|
-
# puts primitive_type
|
|
55
|
-
test_values.each do |value|
|
|
56
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
57
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
58
|
-
|
|
59
|
-
proto.write_field_begin(nil, thrift_type, 15)
|
|
60
|
-
proto.send(writer(primitive_type), value)
|
|
61
|
-
proto.write_field_end
|
|
62
|
-
|
|
63
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
64
|
-
name, type, id = proto.read_field_begin
|
|
65
|
-
expect(type).to eq(thrift_type)
|
|
66
|
-
expect(id).to eq(15)
|
|
67
|
-
read_back = proto.send(reader(primitive_type))
|
|
68
|
-
expect(read_back).to eq(value)
|
|
69
|
-
proto.read_field_end
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "should write a uuid" do
|
|
75
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
76
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
77
|
-
|
|
78
|
-
proto.write_uuid("00112233-4455-6677-8899-aabbccddeeff")
|
|
79
|
-
a = trans.read(trans.available)
|
|
80
|
-
expect(a.unpack('C*')).to eq([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff])
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "should read a uuid" do
|
|
84
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
85
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
86
|
-
|
|
87
|
-
trans.write([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff].pack('C*'))
|
|
88
|
-
uuid = proto.read_uuid
|
|
89
|
-
expect(uuid).to eq("00112233-4455-6677-8899-aabbccddeeff")
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it "should error gracefully when trying to write an invalid uuid" do
|
|
93
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
94
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
95
|
-
expect { proto.write_uuid("invalid") }.to raise_error(Thrift::ProtocolException)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "should encode and decode a monster struct correctly" do
|
|
99
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
100
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
101
|
-
|
|
102
|
-
struct = Thrift::Test::CompactProtoTestStruct.new
|
|
103
|
-
# sets and maps don't hash well... not sure what to do here.
|
|
104
|
-
struct.write(proto)
|
|
105
|
-
|
|
106
|
-
struct2 = Thrift::Test::CompactProtoTestStruct.new
|
|
107
|
-
struct2.read(proto)
|
|
108
|
-
expect(struct2).to eq(struct)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it "should make method calls correctly" do
|
|
112
|
-
client_out_trans = Thrift::MemoryBufferTransport.new
|
|
113
|
-
client_out_proto = Thrift::CompactProtocol.new(client_out_trans)
|
|
114
|
-
|
|
115
|
-
client_in_trans = Thrift::MemoryBufferTransport.new
|
|
116
|
-
client_in_proto = Thrift::CompactProtocol.new(client_in_trans)
|
|
117
|
-
|
|
118
|
-
processor = Thrift::Test::Srv::Processor.new(JankyHandler.new)
|
|
119
|
-
|
|
120
|
-
client = Thrift::Test::Srv::Client.new(client_in_proto, client_out_proto)
|
|
121
|
-
client.send_Janky(1)
|
|
122
|
-
# puts client_out_trans.inspect_buffer
|
|
123
|
-
processor.process(client_out_proto, client_in_proto)
|
|
124
|
-
expect(client.recv_Janky).to eq(2)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "should round-trip wrapped negative seqids in message headers" do
|
|
128
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
129
|
-
writer = Thrift::CompactProtocol.new(trans)
|
|
130
|
-
|
|
131
|
-
writer.write_message_begin("test", Thrift::MessageTypes::CALL, -2147483648)
|
|
132
|
-
writer.write_message_end
|
|
133
|
-
|
|
134
|
-
reader = Thrift::CompactProtocol.new(trans)
|
|
135
|
-
name, type, seqid = reader.read_message_begin
|
|
136
|
-
expect(name).to eq("test")
|
|
137
|
-
expect(type).to eq(Thrift::MessageTypes::CALL)
|
|
138
|
-
expect(seqid).to eq(-2147483648)
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it "should deal with fields following fields that have non-delta ids" do
|
|
142
|
-
brcp = Thrift::Test::BreaksRubyCompactProtocol.new(
|
|
143
|
-
:field1 => "blah",
|
|
144
|
-
:field2 => Thrift::Test::BigFieldIdStruct.new(
|
|
145
|
-
:field1 => "string1",
|
|
146
|
-
:field2 => "string2"),
|
|
147
|
-
:field3 => 3)
|
|
148
|
-
ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
|
|
149
|
-
bytes = ser.serialize(brcp)
|
|
150
|
-
|
|
151
|
-
deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
|
|
152
|
-
brcp2 = Thrift::Test::BreaksRubyCompactProtocol.new
|
|
153
|
-
deser.deserialize(brcp2, bytes)
|
|
154
|
-
expect(brcp2).to eq(brcp)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it "should deserialize an empty map to an empty hash" do
|
|
158
|
-
struct = Thrift::Test::SingleMapTestStruct.new(:i32_map => {})
|
|
159
|
-
ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
|
|
160
|
-
bytes = ser.serialize(struct)
|
|
161
|
-
|
|
162
|
-
deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
|
|
163
|
-
struct2 = Thrift::Test::SingleMapTestStruct.new
|
|
164
|
-
deser.deserialize(struct2, bytes)
|
|
165
|
-
expect(struct).to eq(struct2)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it "should provide a reasonable to_s" do
|
|
169
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
170
|
-
expect(Thrift::CompactProtocol.new(trans).to_s).to eq("compact(memory)")
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
class JankyHandler
|
|
174
|
-
def Janky(i32arg)
|
|
175
|
-
i32arg * 2
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
def writer(sym)
|
|
180
|
-
"write_#{sym.to_s}"
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def reader(sym)
|
|
184
|
-
"read_#{sym.to_s}"
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
describe Thrift::CompactProtocolFactory do
|
|
189
|
-
it "should create a CompactProtocol" do
|
|
190
|
-
expect(Thrift::CompactProtocolFactory.new.get_protocol(double("MockTransport"))).to be_instance_of(Thrift::CompactProtocol)
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
it "should provide a reasonable to_s" do
|
|
194
|
-
expect(Thrift::CompactProtocolFactory.new.to_s).to eq("compact")
|
|
195
|
-
end
|
|
196
|
-
end
|
data/spec/constants_demo_spec.rb
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
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
|
-
$:.unshift File.join(File.dirname(__FILE__), *%w[gen-rb/constants_demo])
|
|
24
|
-
require 'constants_demo_constants'
|
|
25
|
-
|
|
26
|
-
describe 'ConstantsDemo' do
|
|
27
|
-
it 'should have correct integer constants' do
|
|
28
|
-
expect(ConstantsDemo::MyInt).to eq(3)
|
|
29
|
-
expect(ConstantsDemo::Hex_const).to eq(0x0001F)
|
|
30
|
-
expect(ConstantsDemo::Negative_hex_constant).to eq(-0x0001F)
|
|
31
|
-
expect(ConstantsDemo::GEN_ME).to eq(-3523553)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it 'should have correct double constants' do
|
|
35
|
-
expect(ConstantsDemo::GEn_DUB).to eq(325.532)
|
|
36
|
-
expect(ConstantsDemo::GEn_DU).to eq(85.2355)
|
|
37
|
-
expect(ConstantsDemo::E10).to eq(1e+10)
|
|
38
|
-
expect(ConstantsDemo::E11).to eq(-1e+10)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it 'should have correct string constants' do
|
|
42
|
-
expect(ConstantsDemo::GEN_STRING).to eq("asldkjasfd")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it 'should have correct uuid constants' do
|
|
46
|
-
expect(ConstantsDemo::GEN_UUID).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
47
|
-
expect(ConstantsDemo::GEN_GUID).to eq("00112233-4455-6677-8899-aaBBccDDeeFF")
|
|
48
|
-
expect(ConstantsDemo::MY_UUID).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
49
|
-
expect(ConstantsDemo::MY_GUID).to eq("00112233-4455-6677-8899-aaBBccDDeeFF")
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it 'should have correct list constants' do
|
|
53
|
-
expect(ConstantsDemo::GEN_LIST).to be_a(Array)
|
|
54
|
-
expect(ConstantsDemo::GEN_LIST).to eq([235235, 23598352, 3253523])
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'should have correct map constants' do
|
|
58
|
-
expect(ConstantsDemo::GEN_MAP).to be_a(Hash)
|
|
59
|
-
expect(ConstantsDemo::GEN_MAP[35532]).to eq(233)
|
|
60
|
-
expect(ConstantsDemo::GEN_MAP[43523]).to eq(853)
|
|
61
|
-
|
|
62
|
-
expect(ConstantsDemo::GEN_MAP2).to be_a(Hash)
|
|
63
|
-
expect(ConstantsDemo::GEN_MAP2["hello"]).to eq(233)
|
|
64
|
-
expect(ConstantsDemo::GEN_MAP2["lkj98d"]).to eq(853)
|
|
65
|
-
expect(ConstantsDemo::GEN_MAP2['lkjsdf']).to eq(98325)
|
|
66
|
-
|
|
67
|
-
expect(ConstantsDemo::GEN_MAPMAP).to be_a(Hash)
|
|
68
|
-
expect(ConstantsDemo::GEN_MAPMAP[235]).to be_a(Hash)
|
|
69
|
-
expect(ConstantsDemo::GEN_MAPMAP[235][532]).to eq(53255)
|
|
70
|
-
expect(ConstantsDemo::GEN_MAPMAP[235][235]).to eq(235)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'should have correct set constants' do
|
|
74
|
-
expect(ConstantsDemo::GEN_SET).to be_a(Set)
|
|
75
|
-
expect(ConstantsDemo::GEN_SET.size).to eq(2)
|
|
76
|
-
expect(ConstantsDemo::GEN_SET.include?(235)).to be true # added twice, but this is a set
|
|
77
|
-
expect(ConstantsDemo::GEN_SET.include?(53235)).to be true
|
|
78
|
-
|
|
79
|
-
expect(ConstantsDemo::GUID_SET).to be_a(Set)
|
|
80
|
-
expect(ConstantsDemo::GUID_SET.size).to eq(2)
|
|
81
|
-
expect(ConstantsDemo::GUID_SET.include?("00112233-4455-6677-8899-aaBBccDDeeFF")).to be true
|
|
82
|
-
expect(ConstantsDemo::GUID_SET.include?("00000000-4444-CCCC-ffff-0123456789ab")).to be true
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it 'should have correct struct constants' do
|
|
86
|
-
expect(ConstantsDemo::GEN_THING).to be_a(Thrift::Struct)
|
|
87
|
-
expect(ConstantsDemo::GEN_THING.hello).to eq(325)
|
|
88
|
-
expect(ConstantsDemo::GEN_THING.goodbye).to eq(325352)
|
|
89
|
-
expect(ConstantsDemo::GEN_THING.id).to eq("00112233-4455-6677-8899-aaBBccDDeeFF")
|
|
90
|
-
expect(ConstantsDemo::GEN_THING.my_id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
91
|
-
expect(ConstantsDemo::GEN_THING.my_optional_id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
92
|
-
|
|
93
|
-
expect(ConstantsDemo::GEN_WHAT).to be_a(Hash)
|
|
94
|
-
expect(ConstantsDemo::GEN_WHAT[35]).to be_a(Thrift::Struct)
|
|
95
|
-
expect(ConstantsDemo::GEN_WHAT[35].hello).to eq(325)
|
|
96
|
-
expect(ConstantsDemo::GEN_WHAT[35].goodbye).to eq(325352)
|
|
97
|
-
expect(ConstantsDemo::GEN_WHAT[35].id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
98
|
-
expect(ConstantsDemo::GEN_WHAT[35].my_id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
99
|
-
expect(ConstantsDemo::GEN_WHAT[35].my_optional_id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
100
|
-
end
|
|
101
|
-
end
|
data/spec/exception_spec.rb
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
|
4
|
-
# distributed with this work for additional information
|
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
|
7
|
-
# "License"); you may not use this file except in compliance
|
|
8
|
-
# with the License. You may obtain a copy of the License at
|
|
9
|
-
#
|
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
|
13
|
-
# software distributed under the License is distributed on an
|
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
# KIND, either express or implied. See the License for the
|
|
16
|
-
# specific language governing permissions and limitations
|
|
17
|
-
# under the License.
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
require 'spec_helper'
|
|
21
|
-
|
|
22
|
-
describe 'Exception' do
|
|
23
|
-
describe Thrift::Exception do
|
|
24
|
-
it "should have an accessible message" do
|
|
25
|
-
e = Thrift::Exception.new("test message")
|
|
26
|
-
expect(e.message).to eq("test message")
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe Thrift::ApplicationException do
|
|
31
|
-
it "should inherit from Thrift::Exception" do
|
|
32
|
-
expect(Thrift::ApplicationException.superclass).to eq(Thrift::Exception)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should have an accessible type and message" do
|
|
36
|
-
e = Thrift::ApplicationException.new
|
|
37
|
-
expect(e.type).to eq(Thrift::ApplicationException::UNKNOWN)
|
|
38
|
-
expect(e.message).to be_nil
|
|
39
|
-
e = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, "test message")
|
|
40
|
-
expect(e.type).to eq(Thrift::ApplicationException::UNKNOWN_METHOD)
|
|
41
|
-
expect(e.message).to eq("test message")
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should read a struct off of a protocol" do
|
|
45
|
-
prot = double("MockProtocol")
|
|
46
|
-
expect(prot).to receive(:read_struct_begin).ordered
|
|
47
|
-
expect(prot).to receive(:read_field_begin).exactly(3).times.and_return(
|
|
48
|
-
["message", Thrift::Types::STRING, 1],
|
|
49
|
-
["type", Thrift::Types::I32, 2],
|
|
50
|
-
[nil, Thrift::Types::STOP, 0]
|
|
51
|
-
)
|
|
52
|
-
expect(prot).to receive(:read_string).ordered.and_return "test message"
|
|
53
|
-
expect(prot).to receive(:read_i32).ordered.and_return Thrift::ApplicationException::BAD_SEQUENCE_ID
|
|
54
|
-
expect(prot).to receive(:read_field_end).exactly(2).times
|
|
55
|
-
expect(prot).to receive(:read_struct_end).ordered
|
|
56
|
-
|
|
57
|
-
e = Thrift::ApplicationException.new
|
|
58
|
-
e.read(prot)
|
|
59
|
-
expect(e.message).to eq("test message")
|
|
60
|
-
expect(e.type).to eq(Thrift::ApplicationException::BAD_SEQUENCE_ID)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it "should skip bad fields when reading a struct" do
|
|
64
|
-
prot = double("MockProtocol")
|
|
65
|
-
expect(prot).to receive(:read_struct_begin).ordered
|
|
66
|
-
expect(prot).to receive(:read_field_begin).exactly(5).times.and_return(
|
|
67
|
-
["type", Thrift::Types::I32, 2],
|
|
68
|
-
["type", Thrift::Types::STRING, 2],
|
|
69
|
-
["message", Thrift::Types::MAP, 1],
|
|
70
|
-
["message", Thrift::Types::STRING, 3],
|
|
71
|
-
[nil, Thrift::Types::STOP, 0]
|
|
72
|
-
)
|
|
73
|
-
expect(prot).to receive(:read_i32).and_return Thrift::ApplicationException::INVALID_MESSAGE_TYPE
|
|
74
|
-
expect(prot).to receive(:skip).with(Thrift::Types::STRING).twice
|
|
75
|
-
expect(prot).to receive(:skip).with(Thrift::Types::MAP)
|
|
76
|
-
expect(prot).to receive(:read_field_end).exactly(4).times
|
|
77
|
-
expect(prot).to receive(:read_struct_end).ordered
|
|
78
|
-
|
|
79
|
-
e = Thrift::ApplicationException.new
|
|
80
|
-
e.read(prot)
|
|
81
|
-
expect(e.message).to be_nil
|
|
82
|
-
expect(e.type).to eq(Thrift::ApplicationException::INVALID_MESSAGE_TYPE)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "should write a Thrift::ApplicationException struct to the oprot" do
|
|
86
|
-
prot = double("MockProtocol")
|
|
87
|
-
expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
|
|
88
|
-
expect(prot).to receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
|
|
89
|
-
expect(prot).to receive(:write_string).with("test message").ordered
|
|
90
|
-
expect(prot).to receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
|
|
91
|
-
expect(prot).to receive(:write_i32).with(Thrift::ApplicationException::UNKNOWN_METHOD).ordered
|
|
92
|
-
expect(prot).to receive(:write_field_end).twice
|
|
93
|
-
expect(prot).to receive(:write_field_stop).ordered
|
|
94
|
-
expect(prot).to receive(:write_struct_end).ordered
|
|
95
|
-
|
|
96
|
-
e = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, "test message")
|
|
97
|
-
e.write(prot)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it "should skip nil fields when writing to the oprot" do
|
|
101
|
-
prot = double("MockProtocol")
|
|
102
|
-
expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
|
|
103
|
-
expect(prot).to receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
|
|
104
|
-
expect(prot).to receive(:write_string).with("test message").ordered
|
|
105
|
-
expect(prot).to receive(:write_field_end).ordered
|
|
106
|
-
expect(prot).to receive(:write_field_stop).ordered
|
|
107
|
-
expect(prot).to receive(:write_struct_end).ordered
|
|
108
|
-
|
|
109
|
-
e = Thrift::ApplicationException.new(nil, "test message")
|
|
110
|
-
e.write(prot)
|
|
111
|
-
|
|
112
|
-
prot = double("MockProtocol")
|
|
113
|
-
expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
|
|
114
|
-
expect(prot).to receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
|
|
115
|
-
expect(prot).to receive(:write_i32).with(Thrift::ApplicationException::BAD_SEQUENCE_ID).ordered
|
|
116
|
-
expect(prot).to receive(:write_field_end).ordered
|
|
117
|
-
expect(prot).to receive(:write_field_stop).ordered
|
|
118
|
-
expect(prot).to receive(:write_struct_end).ordered
|
|
119
|
-
|
|
120
|
-
e = Thrift::ApplicationException.new(Thrift::ApplicationException::BAD_SEQUENCE_ID)
|
|
121
|
-
e.write(prot)
|
|
122
|
-
|
|
123
|
-
prot = double("MockProtocol")
|
|
124
|
-
expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
|
|
125
|
-
expect(prot).to receive(:write_field_stop).ordered
|
|
126
|
-
expect(prot).to receive(:write_struct_end).ordered
|
|
127
|
-
|
|
128
|
-
e = Thrift::ApplicationException.new(nil)
|
|
129
|
-
e.write(prot)
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
describe Thrift::ProtocolException do
|
|
134
|
-
it "should have an accessible type" do
|
|
135
|
-
prot = Thrift::ProtocolException.new(Thrift::ProtocolException::SIZE_LIMIT, "message")
|
|
136
|
-
expect(prot.type).to eq(Thrift::ProtocolException::SIZE_LIMIT)
|
|
137
|
-
expect(prot.message).to eq("message")
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
data/spec/flat_spec.rb
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
-
# or more contributor license agreements. See the NOTICE file
|
|
4
|
-
# distributed with this work for additional information
|
|
5
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
-
# to you under the Apache License, Version 2.0 (the
|
|
7
|
-
# "License"); you may not use this file except in compliance
|
|
8
|
-
# with the License. You may obtain a copy of the License at
|
|
9
|
-
#
|
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
#
|
|
12
|
-
# Unless required by applicable law or agreed to in writing,
|
|
13
|
-
# software distributed under the License is distributed on an
|
|
14
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
-
# KIND, either express or implied. See the License for the
|
|
16
|
-
# specific language governing permissions and limitations
|
|
17
|
-
# under the License.
|
|
18
|
-
#
|
|
19
|
-
|
|
20
|
-
require 'spec_helper'
|
|
21
|
-
|
|
22
|
-
describe 'generation' do
|
|
23
|
-
before do
|
|
24
|
-
require 'namespaced_nonblocking_service'
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "did not generate the wrong files" do
|
|
28
|
-
prefix = File.expand_path("../gen-rb/flat", __FILE__)
|
|
29
|
-
["namespaced_spec_namespace/namespaced_nonblocking_service.rb",
|
|
30
|
-
"namespaced_spec_namespace/thrift_namespaced_spec_constants.rb",
|
|
31
|
-
"namespaced_spec_namespace/thrift_namespaced_spec_types.rb",
|
|
32
|
-
"other_namespace/referenced_constants.rb",
|
|
33
|
-
"other_namespace/referenced_types.rb"
|
|
34
|
-
].each do |name|
|
|
35
|
-
expect(File.exist?(File.join(prefix, name))).not_to be_truthy
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "generated the right files" do
|
|
40
|
-
prefix = File.expand_path("../gen-rb/flat", __FILE__)
|
|
41
|
-
["namespaced_nonblocking_service.rb",
|
|
42
|
-
"thrift_namespaced_spec_constants.rb",
|
|
43
|
-
"thrift_namespaced_spec_types.rb",
|
|
44
|
-
"referenced_constants.rb",
|
|
45
|
-
"referenced_types.rb"
|
|
46
|
-
].each do |name|
|
|
47
|
-
expect(File.exist?(File.join(prefix, name))).to be_truthy
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "has a service class in the right place" do
|
|
52
|
-
expect(defined?(NamespacedSpecNamespace::NamespacedNonblockingService)).to be_truthy
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "has a struct in the right place" do
|
|
56
|
-
expect(defined?(NamespacedSpecNamespace::Hello)).to be_truthy
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "required an included file" do
|
|
60
|
-
expect(defined?(OtherNamespace::SomeEnum)).to be_truthy
|
|
61
|
-
end
|
|
62
|
-
end
|