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/bytes_spec.rb
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
#
|
|
4
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
5
|
-
# or more contributor license agreements. See the NOTICE file
|
|
6
|
-
# distributed with this work for additional information
|
|
7
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
8
|
-
# to you under the Apache License, Version 2.0 (the
|
|
9
|
-
# "License"); you may not use this file except in compliance
|
|
10
|
-
# with the License. You may obtain a copy of the License at
|
|
11
|
-
#
|
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
#
|
|
14
|
-
# Unless required by applicable law or agreed to in writing,
|
|
15
|
-
# software distributed under the License is distributed on an
|
|
16
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
17
|
-
# KIND, either express or implied. See the License for the
|
|
18
|
-
# specific language governing permissions and limitations
|
|
19
|
-
# under the License.
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'spec_helper'
|
|
23
|
-
|
|
24
|
-
describe Thrift::Bytes do
|
|
25
|
-
describe '.empty_byte_buffer' do
|
|
26
|
-
it 'should create an empty buffer' do
|
|
27
|
-
b = Thrift::Bytes.empty_byte_buffer
|
|
28
|
-
expect(b.length).to eq(0)
|
|
29
|
-
expect(b.encoding).to eq(Encoding::BINARY)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it 'should create an empty buffer of given size' do
|
|
33
|
-
b = Thrift::Bytes.empty_byte_buffer 2
|
|
34
|
-
expect(b.length).to eq(2)
|
|
35
|
-
expect(b.getbyte(0)).to eq(0)
|
|
36
|
-
expect(b.getbyte(1)).to eq(0)
|
|
37
|
-
expect(b.encoding).to eq(Encoding::BINARY)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe '.force_binary_encoding' do
|
|
42
|
-
it 'should change encoding' do
|
|
43
|
-
e = 'STRING'.encode('UTF-8')
|
|
44
|
-
expect(e.encoding).not_to eq(Encoding::BINARY)
|
|
45
|
-
a = Thrift::Bytes.force_binary_encoding e
|
|
46
|
-
expect(a.encoding).to eq(Encoding::BINARY)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'should return the same frozen binary string unchanged' do
|
|
50
|
-
e = 'STRING'.b.freeze
|
|
51
|
-
a = Thrift::Bytes.force_binary_encoding(e)
|
|
52
|
-
expect(a).to equal(e)
|
|
53
|
-
expect(a.encoding).to eq(Encoding::BINARY)
|
|
54
|
-
expect(a).to be_frozen
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
it 'should duplicate a frozen non-binary string before changing encoding' do
|
|
58
|
-
e = 'STRING'.encode('UTF-8').freeze
|
|
59
|
-
a = Thrift::Bytes.force_binary_encoding(e)
|
|
60
|
-
expect(a).not_to equal(e)
|
|
61
|
-
expect(a.encoding).to eq(Encoding::BINARY)
|
|
62
|
-
expect(e.encoding).to eq(Encoding::UTF_8)
|
|
63
|
-
expect(e).to be_frozen
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe '.get_string_byte' do
|
|
68
|
-
it 'should get the byte at index' do
|
|
69
|
-
s = "\x41\x42"
|
|
70
|
-
expect(Thrift::Bytes.get_string_byte(s, 0)).to eq(0x41)
|
|
71
|
-
expect(Thrift::Bytes.get_string_byte(s, 1)).to eq(0x42)
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe '.set_string_byte' do
|
|
76
|
-
it 'should set byte value at index' do
|
|
77
|
-
s = "\x41\x42".b
|
|
78
|
-
Thrift::Bytes.set_string_byte(s, 0, 0x43)
|
|
79
|
-
expect(s.getbyte(0)).to eq(0x43)
|
|
80
|
-
expect(s).to eq('CB')
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
describe '.convert_to_utf8_byte_buffer' do
|
|
85
|
-
it 'should convert UTF-8 String to byte buffer' do
|
|
86
|
-
e = "\u20AC".encode('UTF-8') # a string with euro sign character U+20AC
|
|
87
|
-
expect(e.length).to eq(1)
|
|
88
|
-
|
|
89
|
-
a = Thrift::Bytes.convert_to_utf8_byte_buffer e
|
|
90
|
-
expect(a.encoding).to eq(Encoding::BINARY)
|
|
91
|
-
expect(a.length).to eq(3)
|
|
92
|
-
expect(a.unpack('C*')).to eq([0xE2, 0x82, 0xAC])
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it 'should convert ISO-8859-15 String to UTF-8 byte buffer' do
|
|
96
|
-
# Assumptions
|
|
97
|
-
e = "\u20AC".encode('ISO-8859-15') # a string with euro sign character U+20AC, then converted to ISO-8859-15
|
|
98
|
-
expect(e.length).to eq(1)
|
|
99
|
-
expect(e.unpack('C*')).to eq([0xA4]) # euro sign is a different code point in ISO-8859-15
|
|
100
|
-
|
|
101
|
-
a = Thrift::Bytes.convert_to_utf8_byte_buffer e
|
|
102
|
-
expect(a.encoding).to eq(Encoding::BINARY)
|
|
103
|
-
expect(a.length).to eq(3)
|
|
104
|
-
expect(a.unpack('C*')).to eq([0xE2, 0x82, 0xAC])
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
describe '.convert_to_string' do
|
|
109
|
-
it 'should convert UTF-8 byte buffer to a UTF-8 String' do
|
|
110
|
-
e = [0xE2, 0x82, 0xAC].pack("C*")
|
|
111
|
-
expect(e.encoding).to eq(Encoding::BINARY)
|
|
112
|
-
a = Thrift::Bytes.convert_to_string e
|
|
113
|
-
expect(a.encoding).to eq(Encoding::UTF_8)
|
|
114
|
-
expect(a).to eq("\u20AC")
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
end
|
data/spec/client_spec.rb
DELETED
|
@@ -1,167 +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 'Client' do
|
|
24
|
-
class ClientSpec
|
|
25
|
-
include Thrift::Client
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
class EmptyArgs
|
|
29
|
-
def write(_prot)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
before(:each) do
|
|
34
|
-
@prot = double("MockProtocol")
|
|
35
|
-
@client = ClientSpec.new(@prot)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe Thrift::Client do
|
|
39
|
-
it "should re-use iprot for oprot if not otherwise specified" do
|
|
40
|
-
expect(@client.instance_variable_get(:'@iprot')).to eql(@prot)
|
|
41
|
-
expect(@client.instance_variable_get(:'@oprot')).to eql(@prot)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should send a test message" do
|
|
45
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 0)
|
|
46
|
-
mock_args = double('#<TestMessage_args:mock>')
|
|
47
|
-
expect(mock_args).to receive(:foo=).with('foo')
|
|
48
|
-
expect(mock_args).to receive(:bar=).with(42)
|
|
49
|
-
expect(mock_args).to receive(:write).with(@prot)
|
|
50
|
-
expect(@prot).to receive(:write_message_end)
|
|
51
|
-
expect(@prot).to receive(:trans) do
|
|
52
|
-
double('trans').tap do |trans|
|
|
53
|
-
expect(trans).to receive(:flush)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
klass = double("TestMessage_args", :new => mock_args)
|
|
57
|
-
@client.send_message('testMessage', klass, :foo => 'foo', :bar => 42)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "should increment the sequence id when sending messages" do
|
|
61
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 0).ordered
|
|
62
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage2', Thrift::MessageTypes::CALL, 1).ordered
|
|
63
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage3', Thrift::MessageTypes::CALL, 2).ordered
|
|
64
|
-
allow(@prot).to receive(:write_message_end)
|
|
65
|
-
allow(@prot).to receive(:trans).and_return(double("trans", :flush => nil))
|
|
66
|
-
|
|
67
|
-
args_class = double("ArgsClass", :new => EmptyArgs.new)
|
|
68
|
-
@client.send_message('testMessage', args_class)
|
|
69
|
-
@client.send_message('testMessage2', args_class)
|
|
70
|
-
@client.send_message('testMessage3', args_class)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "should keep pending reply sequence ids in FIFO order" do
|
|
74
|
-
expect(@prot).to receive(:write_message_begin).with('first', Thrift::MessageTypes::CALL, 0).ordered
|
|
75
|
-
expect(@prot).to receive(:write_message_begin).with('second', Thrift::MessageTypes::CALL, 1).ordered
|
|
76
|
-
allow(@prot).to receive(:write_message_end)
|
|
77
|
-
allow(@prot).to receive(:trans).and_return(double("trans", :flush => nil))
|
|
78
|
-
|
|
79
|
-
args_class = double("ArgsClass", :new => EmptyArgs.new)
|
|
80
|
-
@client.send_message('first', args_class)
|
|
81
|
-
@client.send_message('second', args_class)
|
|
82
|
-
|
|
83
|
-
expect {
|
|
84
|
-
@client.validate_message_begin('first', Thrift::MessageTypes::REPLY, 0, 'first')
|
|
85
|
-
}.not_to raise_error
|
|
86
|
-
expect {
|
|
87
|
-
@client.validate_message_begin('second', Thrift::MessageTypes::REPLY, 1, 'second')
|
|
88
|
-
}.not_to raise_error
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "should receive a test message" do
|
|
92
|
-
expect(@prot).to receive(:read_message_begin).and_return [nil, Thrift::MessageTypes::CALL, 0]
|
|
93
|
-
expect(@prot).to receive(:read_message_end)
|
|
94
|
-
mock_klass = double("#<MockClass:mock>")
|
|
95
|
-
expect(mock_klass).to receive(:read).with(@prot)
|
|
96
|
-
@client.receive_message_begin()
|
|
97
|
-
@client.receive_message(double("MockClass", :new => mock_klass))
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
it "should raise BAD_SEQUENCE_ID for mismatched replies" do
|
|
101
|
-
@client.instance_variable_set(:@pending_seqids, [0])
|
|
102
|
-
|
|
103
|
-
expect {
|
|
104
|
-
@client.validate_message_begin('testMessage', Thrift::MessageTypes::REPLY, 1, 'testMessage')
|
|
105
|
-
}.to raise_error(Thrift::ApplicationException) { |error|
|
|
106
|
-
expect(error.type).to eq(Thrift::ApplicationException::BAD_SEQUENCE_ID)
|
|
107
|
-
}
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "should raise WRONG_METHOD_NAME for unexpected replies" do
|
|
111
|
-
@client.instance_variable_set(:@pending_seqids, [0])
|
|
112
|
-
|
|
113
|
-
expect {
|
|
114
|
-
@client.validate_message_begin('otherMessage', Thrift::MessageTypes::REPLY, 0, 'testMessage')
|
|
115
|
-
}.to raise_error(Thrift::ApplicationException) { |error|
|
|
116
|
-
expect(error.type).to eq(Thrift::ApplicationException::WRONG_METHOD_NAME)
|
|
117
|
-
}
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
it "should raise INVALID_MESSAGE_TYPE for non-reply messages" do
|
|
121
|
-
@client.instance_variable_set(:@pending_seqids, [0])
|
|
122
|
-
|
|
123
|
-
expect {
|
|
124
|
-
@client.validate_message_begin('testMessage', Thrift::MessageTypes::CALL, 0, 'testMessage')
|
|
125
|
-
}.to raise_error(Thrift::ApplicationException) { |error|
|
|
126
|
-
expect(error.type).to eq(Thrift::ApplicationException::INVALID_MESSAGE_TYPE)
|
|
127
|
-
}
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "should raise received application exceptions" do
|
|
131
|
-
expect(@prot).to receive(:read_message_end)
|
|
132
|
-
server_exception = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN, "boom")
|
|
133
|
-
expect(server_exception).to receive(:read).with(@prot)
|
|
134
|
-
expect(Thrift::ApplicationException).to receive(:new).and_return(server_exception)
|
|
135
|
-
@client.instance_variable_set(:@pending_seqids, [0])
|
|
136
|
-
|
|
137
|
-
expect {
|
|
138
|
-
@client.validate_message_begin('testMessage', Thrift::MessageTypes::EXCEPTION, 0, 'testMessage')
|
|
139
|
-
}.to raise_error(Thrift::ApplicationException, "boom")
|
|
140
|
-
expect(@client.instance_variable_get(:@pending_seqids)).to be_empty
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
it "should roll sequence ids across the signed int32 boundary" do
|
|
144
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, Thrift::Client::MAX_SEQUENCE_ID).ordered
|
|
145
|
-
expect(@prot).to receive(:write_message_begin).with('testMessage2', Thrift::MessageTypes::CALL, Thrift::Client::MIN_SEQUENCE_ID).ordered
|
|
146
|
-
allow(@prot).to receive(:write_message_end)
|
|
147
|
-
allow(@prot).to receive(:trans).and_return(double("trans", :flush => nil))
|
|
148
|
-
|
|
149
|
-
@client.instance_variable_set(:@seqid, Thrift::Client::MAX_SEQUENCE_ID)
|
|
150
|
-
args_class = double("ArgsClass", :new => EmptyArgs.new)
|
|
151
|
-
@client.send_message('testMessage', args_class)
|
|
152
|
-
@client.send_message('testMessage2', args_class)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it "should close the transport if an error occurs while sending a message" do
|
|
156
|
-
allow(@prot).to receive(:write_message_begin)
|
|
157
|
-
expect(@prot).not_to receive(:write_message_end)
|
|
158
|
-
mock_args = double("#<TestMessage_args:mock>")
|
|
159
|
-
expect(mock_args).to receive(:write).with(@prot).and_raise(StandardError)
|
|
160
|
-
trans = double("MockTransport")
|
|
161
|
-
allow(@prot).to receive(:trans).and_return(trans)
|
|
162
|
-
expect(trans).to receive(:close)
|
|
163
|
-
klass = double("TestMessage_args", :new => mock_args)
|
|
164
|
-
expect { @client.send_message("testMessage", klass) }.to raise_error(StandardError)
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
#
|
|
4
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
5
|
-
# or more contributor license agreements. See the NOTICE file
|
|
6
|
-
# distributed with this work for additional information
|
|
7
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
8
|
-
# to you under the Apache License, Version 2.0 (the
|
|
9
|
-
# "License"); you may not use this file except in compliance
|
|
10
|
-
# with the License. You may obtain a copy of the License at
|
|
11
|
-
#
|
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
#
|
|
14
|
-
# Unless required by applicable law or agreed to in writing,
|
|
15
|
-
# software distributed under the License is distributed on an
|
|
16
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
17
|
-
# KIND, either express or implied. See the License for the
|
|
18
|
-
# specific language governing permissions and limitations
|
|
19
|
-
# under the License.
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'spec_helper'
|
|
23
|
-
|
|
24
|
-
describe Thrift::CompactProtocol do
|
|
25
|
-
INTEGER_BOUNDARY_TESTS = {
|
|
26
|
-
:i32 => [-(2**31), (2**31) - 1],
|
|
27
|
-
:i64 => [-(2**63), (2**63) - 1]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
INTEGER_MINIMUM_ENCODINGS = {
|
|
31
|
-
:i32 => [0xff, 0xff, 0xff, 0xff, 0x0f],
|
|
32
|
-
:i64 => [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
TESTS = {
|
|
36
|
-
:byte => (-127..127).to_a,
|
|
37
|
-
:i16 => (0..14).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
|
|
38
|
-
:i32 => (0..30).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
|
|
39
|
-
:i64 => (0..62).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
|
|
40
|
-
:string => ["", "1", "short", "fourteen123456", "fifteen12345678", "unicode characters: \u20AC \u20AD", "1" * 127, "1" * 3000],
|
|
41
|
-
:binary => ["", "\001", "\001" * 5, "\001" * 14, "\001" * 15, "\001" * 127, "\001" * 3000],
|
|
42
|
-
:double => [0.0, 1.0, -1.0, 1.1, -1.1, 10000000.1, 1.0/0.0, -1.0/0.0],
|
|
43
|
-
:bool => [true, false]
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
it "should encode and decode naked primitives correctly" do
|
|
47
|
-
TESTS.each_pair do |primitive_type, test_values|
|
|
48
|
-
test_values.each do |value|
|
|
49
|
-
# puts "testing #{value}" if primitive_type == :i64
|
|
50
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
51
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
52
|
-
|
|
53
|
-
proto.send(writer(primitive_type), value)
|
|
54
|
-
# puts "buf: #{trans.inspect_buffer}" if primitive_type == :i64
|
|
55
|
-
read_back = proto.send(reader(primitive_type))
|
|
56
|
-
expect(read_back).to eq(value)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "should encode and decode primitives in fields correctly" do
|
|
62
|
-
TESTS.each_pair do |primitive_type, test_values|
|
|
63
|
-
final_primitive_type = primitive_type == :binary ? :string : primitive_type
|
|
64
|
-
thrift_type = Thrift::Types.const_get(final_primitive_type.to_s.upcase)
|
|
65
|
-
# puts primitive_type
|
|
66
|
-
test_values.each do |value|
|
|
67
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
68
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
69
|
-
|
|
70
|
-
proto.write_field_begin(nil, thrift_type, 15)
|
|
71
|
-
proto.send(writer(primitive_type), value)
|
|
72
|
-
proto.write_field_end
|
|
73
|
-
|
|
74
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
75
|
-
name, type, id = proto.read_field_begin
|
|
76
|
-
expect(type).to eq(thrift_type)
|
|
77
|
-
expect(id).to eq(15)
|
|
78
|
-
read_back = proto.send(reader(primitive_type))
|
|
79
|
-
expect(read_back).to eq(value)
|
|
80
|
-
proto.read_field_end
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "should round-trip signed integer boundaries correctly" do
|
|
86
|
-
INTEGER_BOUNDARY_TESTS.each_pair do |primitive_type, test_values|
|
|
87
|
-
test_values.each do |value|
|
|
88
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
89
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
90
|
-
|
|
91
|
-
proto.send(writer(primitive_type), value)
|
|
92
|
-
expect(proto.send(reader(primitive_type))).to eq(value)
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "should encode signed integer minima with the canonical zigzag varint bytes" do
|
|
98
|
-
INTEGER_MINIMUM_ENCODINGS.each_pair do |primitive_type, expected_bytes|
|
|
99
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
100
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
101
|
-
|
|
102
|
-
proto.send(writer(primitive_type), INTEGER_BOUNDARY_TESTS.fetch(primitive_type).first)
|
|
103
|
-
expect(trans.read(trans.available).bytes).to eq(expected_bytes)
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
it "should decode i32 minima from direct canonical zigzag bytes" do
|
|
108
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
109
|
-
trans.write(INTEGER_MINIMUM_ENCODINGS[:i32].pack("C*"))
|
|
110
|
-
|
|
111
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
112
|
-
expect(proto.read_i32).to eq(INTEGER_BOUNDARY_TESTS[:i32].first)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it "should decode i64 minima from direct canonical zigzag bytes" do
|
|
116
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
117
|
-
trans.write(INTEGER_MINIMUM_ENCODINGS[:i64].pack("C*"))
|
|
118
|
-
|
|
119
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
120
|
-
expect(proto.read_i64).to eq(INTEGER_BOUNDARY_TESTS[:i64].first)
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it "should read binary values with multi-byte varint32 lengths" do
|
|
124
|
-
payload = "x" * 128
|
|
125
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
126
|
-
trans.write([0x80, 0x01].pack("C*"))
|
|
127
|
-
trans.write(payload)
|
|
128
|
-
|
|
129
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
130
|
-
expect(proto.read_binary).to eq(payload)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
it "should write a uuid" do
|
|
134
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
135
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
136
|
-
|
|
137
|
-
proto.write_uuid("00112233-4455-6677-8899-aabbccddeeff")
|
|
138
|
-
a = trans.read(trans.available)
|
|
139
|
-
expect(a.unpack('C*')).to eq([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff])
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "should read a uuid" do
|
|
143
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
144
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
145
|
-
|
|
146
|
-
trans.write([0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff].pack('C*'))
|
|
147
|
-
uuid = proto.read_uuid
|
|
148
|
-
expect(uuid).to eq("00112233-4455-6677-8899-aabbccddeeff")
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it "should error gracefully when trying to write an invalid uuid" do
|
|
152
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
153
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
154
|
-
expect { proto.write_uuid("invalid") }.to raise_error(Thrift::ProtocolException)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it "should encode and decode a monster struct correctly" do
|
|
158
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
159
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
160
|
-
|
|
161
|
-
struct = Thrift::Test::CompactProtoTestStruct.new
|
|
162
|
-
# sets and maps don't hash well... not sure what to do here.
|
|
163
|
-
struct.write(proto)
|
|
164
|
-
|
|
165
|
-
struct2 = Thrift::Test::CompactProtoTestStruct.new
|
|
166
|
-
struct2.read(proto)
|
|
167
|
-
expect(struct2).to eq(struct)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it "should make method calls correctly" do
|
|
171
|
-
client_out_trans = Thrift::MemoryBufferTransport.new
|
|
172
|
-
client_out_proto = Thrift::CompactProtocol.new(client_out_trans)
|
|
173
|
-
|
|
174
|
-
client_in_trans = Thrift::MemoryBufferTransport.new
|
|
175
|
-
client_in_proto = Thrift::CompactProtocol.new(client_in_trans)
|
|
176
|
-
|
|
177
|
-
processor = Thrift::Test::Srv::Processor.new(JankyHandler.new)
|
|
178
|
-
|
|
179
|
-
client = Thrift::Test::Srv::Client.new(client_in_proto, client_out_proto)
|
|
180
|
-
client.send_Janky(1)
|
|
181
|
-
# puts client_out_trans.inspect_buffer
|
|
182
|
-
processor.process(client_out_proto, client_in_proto)
|
|
183
|
-
expect(client.recv_Janky).to eq(2)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it "should round-trip wrapped negative seqids in message headers" do
|
|
187
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
188
|
-
writer = Thrift::CompactProtocol.new(trans)
|
|
189
|
-
|
|
190
|
-
writer.write_message_begin("test", Thrift::MessageTypes::CALL, -2147483648)
|
|
191
|
-
writer.write_message_end
|
|
192
|
-
|
|
193
|
-
reader = Thrift::CompactProtocol.new(trans)
|
|
194
|
-
name, type, seqid = reader.read_message_begin
|
|
195
|
-
expect(name).to eq("test")
|
|
196
|
-
expect(type).to eq(Thrift::MessageTypes::CALL)
|
|
197
|
-
expect(seqid).to eq(-2147483648)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
it "should deal with fields following fields that have non-delta ids" do
|
|
201
|
-
brcp = Thrift::Test::BreaksRubyCompactProtocol.new(
|
|
202
|
-
:field1 => "blah",
|
|
203
|
-
:field2 => Thrift::Test::BigFieldIdStruct.new(
|
|
204
|
-
:field1 => "string1",
|
|
205
|
-
:field2 => "string2"),
|
|
206
|
-
:field3 => 3)
|
|
207
|
-
ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
|
|
208
|
-
bytes = ser.serialize(brcp)
|
|
209
|
-
|
|
210
|
-
deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
|
|
211
|
-
brcp2 = Thrift::Test::BreaksRubyCompactProtocol.new
|
|
212
|
-
deser.deserialize(brcp2, bytes)
|
|
213
|
-
expect(brcp2).to eq(brcp)
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
it "should deserialize an empty map to an empty hash" do
|
|
217
|
-
struct = Thrift::Test::SingleMapTestStruct.new(:i32_map => {})
|
|
218
|
-
ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
|
|
219
|
-
bytes = ser.serialize(struct)
|
|
220
|
-
|
|
221
|
-
deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
|
|
222
|
-
struct2 = Thrift::Test::SingleMapTestStruct.new
|
|
223
|
-
deser.deserialize(struct2, bytes)
|
|
224
|
-
expect(struct).to eq(struct2)
|
|
225
|
-
end
|
|
226
|
-
|
|
227
|
-
it "should provide a reasonable to_s" do
|
|
228
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
229
|
-
expect(Thrift::CompactProtocol.new(trans).to_s).to eq("compact(memory)")
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
it "should write a frozen non-binary string without mutating the input" do
|
|
233
|
-
trans = Thrift::MemoryBufferTransport.new
|
|
234
|
-
prot = Thrift::CompactProtocol.new(trans)
|
|
235
|
-
buffer = "abc \u20AC".encode("UTF-8").freeze
|
|
236
|
-
|
|
237
|
-
prot.write_binary(buffer)
|
|
238
|
-
|
|
239
|
-
expect(buffer.encoding).to eq(Encoding::UTF_8)
|
|
240
|
-
expect(buffer).to be_frozen
|
|
241
|
-
expect(trans.read(trans.available).unpack("C*")).to eq([0x07, 0x61, 0x62, 0x63, 0x20, 0xE2, 0x82, 0xAC])
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
it "should reject a varint with more than 10 continuation bytes" do
|
|
245
|
-
trans = Thrift::MemoryBufferTransport.new(([0x80] * 11).pack("C*"))
|
|
246
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
247
|
-
expect { proto.read_i64 }.to raise_error(Thrift::ProtocolException) do |e|
|
|
248
|
-
expect(e.type).to eq(Thrift::ProtocolException::INVALID_DATA)
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
it "should accept a valid 10-byte varint" do
|
|
253
|
-
trans = Thrift::MemoryBufferTransport.new((([0x80] * 9) + [0x01]).pack("C*"))
|
|
254
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
255
|
-
expect { proto.read_i64 }.not_to raise_error
|
|
256
|
-
end
|
|
257
|
-
|
|
258
|
-
it "should reject a 32-bit varint with more than 5 continuation bytes" do
|
|
259
|
-
trans = Thrift::MemoryBufferTransport.new(([0x80] * 6).pack("C*"))
|
|
260
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
261
|
-
expect { proto.read_i32 }.to raise_error(Thrift::ProtocolException) do |e|
|
|
262
|
-
expect(e.type).to eq(Thrift::ProtocolException::INVALID_DATA)
|
|
263
|
-
end
|
|
264
|
-
end
|
|
265
|
-
|
|
266
|
-
it "should accept a valid 5-byte varint for i32" do
|
|
267
|
-
trans = Thrift::MemoryBufferTransport.new((([0x80] * 4) + [0x0f]).pack("C*"))
|
|
268
|
-
proto = Thrift::CompactProtocol.new(trans)
|
|
269
|
-
expect { proto.read_i32 }.not_to raise_error
|
|
270
|
-
end
|
|
271
|
-
|
|
272
|
-
class JankyHandler
|
|
273
|
-
def Janky(i32arg)
|
|
274
|
-
i32arg * 2
|
|
275
|
-
end
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
def writer(sym)
|
|
279
|
-
"write_#{sym.to_s}"
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
def reader(sym)
|
|
283
|
-
"read_#{sym.to_s}"
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
describe Thrift::CompactProtocolFactory do
|
|
288
|
-
it "should create a CompactProtocol" do
|
|
289
|
-
expect(Thrift::CompactProtocolFactory.new.get_protocol(double("MockTransport"))).to be_instance_of(Thrift::CompactProtocol)
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
it "should provide a reasonable to_s" do
|
|
293
|
-
expect(Thrift::CompactProtocolFactory.new.to_s).to eq("compact")
|
|
294
|
-
end
|
|
295
|
-
end
|
data/spec/constants_demo_spec.rb
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
#
|
|
4
|
-
# Licensed to the Apache Software Foundation (ASF) under one
|
|
5
|
-
# or more contributor license agreements. See the NOTICE file
|
|
6
|
-
# distributed with this work for additional information
|
|
7
|
-
# regarding copyright ownership. The ASF licenses this file
|
|
8
|
-
# to you under the Apache License, Version 2.0 (the
|
|
9
|
-
# "License"); you may not use this file except in compliance
|
|
10
|
-
# with the License. You may obtain a copy of the License at
|
|
11
|
-
#
|
|
12
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
#
|
|
14
|
-
# Unless required by applicable law or agreed to in writing,
|
|
15
|
-
# software distributed under the License is distributed on an
|
|
16
|
-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
17
|
-
# KIND, either express or implied. See the License for the
|
|
18
|
-
# specific language governing permissions and limitations
|
|
19
|
-
# under the License.
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
require 'spec_helper'
|
|
23
|
-
|
|
24
|
-
$:.unshift File.join(File.dirname(__FILE__), *%w[gen-rb/constants_demo])
|
|
25
|
-
require 'constants_demo_constants'
|
|
26
|
-
|
|
27
|
-
describe 'ConstantsDemo' do
|
|
28
|
-
it 'should have correct integer constants' do
|
|
29
|
-
expect(ConstantsDemo::MyInt).to eq(3)
|
|
30
|
-
expect(ConstantsDemo::Hex_const).to eq(0x0001F)
|
|
31
|
-
expect(ConstantsDemo::Negative_hex_constant).to eq(-0x0001F)
|
|
32
|
-
expect(ConstantsDemo::GEN_ME).to eq(-3523553)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'should have correct double constants' do
|
|
36
|
-
expect(ConstantsDemo::GEn_DUB).to eq(325.532)
|
|
37
|
-
expect(ConstantsDemo::GEn_DU).to eq(85.2355)
|
|
38
|
-
expect(ConstantsDemo::E10).to eq(1e+10)
|
|
39
|
-
expect(ConstantsDemo::E11).to eq(-1e+10)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'should have correct string constants' do
|
|
43
|
-
expect(ConstantsDemo::GEN_STRING).to eq("asldkjasfd")
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it 'should have correct uuid constants' do
|
|
47
|
-
expect(ConstantsDemo::GEN_UUID).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
48
|
-
expect(ConstantsDemo::GEN_GUID).to eq("00112233-4455-6677-8899-aaBBccDDeeFF")
|
|
49
|
-
expect(ConstantsDemo::MY_UUID).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
50
|
-
expect(ConstantsDemo::MY_GUID).to eq("00112233-4455-6677-8899-aaBBccDDeeFF")
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it 'should have correct list constants' do
|
|
54
|
-
expect(ConstantsDemo::GEN_LIST).to be_a(Array)
|
|
55
|
-
expect(ConstantsDemo::GEN_LIST).to eq([235235, 23598352, 3253523])
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it 'should have correct map constants' do
|
|
59
|
-
expect(ConstantsDemo::GEN_MAP).to be_a(Hash)
|
|
60
|
-
expect(ConstantsDemo::GEN_MAP[35532]).to eq(233)
|
|
61
|
-
expect(ConstantsDemo::GEN_MAP[43523]).to eq(853)
|
|
62
|
-
|
|
63
|
-
expect(ConstantsDemo::GEN_MAP2).to be_a(Hash)
|
|
64
|
-
expect(ConstantsDemo::GEN_MAP2["hello"]).to eq(233)
|
|
65
|
-
expect(ConstantsDemo::GEN_MAP2["lkj98d"]).to eq(853)
|
|
66
|
-
expect(ConstantsDemo::GEN_MAP2['lkjsdf']).to eq(98325)
|
|
67
|
-
|
|
68
|
-
expect(ConstantsDemo::GEN_MAPMAP).to be_a(Hash)
|
|
69
|
-
expect(ConstantsDemo::GEN_MAPMAP[235]).to be_a(Hash)
|
|
70
|
-
expect(ConstantsDemo::GEN_MAPMAP[235][532]).to eq(53255)
|
|
71
|
-
expect(ConstantsDemo::GEN_MAPMAP[235][235]).to eq(235)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'should have correct set constants' do
|
|
75
|
-
expect(ConstantsDemo::GEN_SET).to be_a(Set)
|
|
76
|
-
expect(ConstantsDemo::GEN_SET.size).to eq(2)
|
|
77
|
-
expect(ConstantsDemo::GEN_SET.include?(235)).to be true # added twice, but this is a set
|
|
78
|
-
expect(ConstantsDemo::GEN_SET.include?(53235)).to be true
|
|
79
|
-
|
|
80
|
-
expect(ConstantsDemo::GUID_SET).to be_a(Set)
|
|
81
|
-
expect(ConstantsDemo::GUID_SET.size).to eq(2)
|
|
82
|
-
expect(ConstantsDemo::GUID_SET.include?("00112233-4455-6677-8899-aaBBccDDeeFF")).to be true
|
|
83
|
-
expect(ConstantsDemo::GUID_SET.include?("00000000-4444-CCCC-ffff-0123456789ab")).to be true
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it 'should have correct struct constants' do
|
|
87
|
-
expect(ConstantsDemo::GEN_THING).to be_a(Thrift::Struct)
|
|
88
|
-
expect(ConstantsDemo::GEN_THING.hello).to eq(325)
|
|
89
|
-
expect(ConstantsDemo::GEN_THING.goodbye).to eq(325352)
|
|
90
|
-
expect(ConstantsDemo::GEN_THING.id).to eq("00112233-4455-6677-8899-aaBBccDDeeFF")
|
|
91
|
-
expect(ConstantsDemo::GEN_THING.my_id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
92
|
-
expect(ConstantsDemo::GEN_THING.my_optional_id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
93
|
-
|
|
94
|
-
expect(ConstantsDemo::GEN_WHAT).to be_a(Hash)
|
|
95
|
-
expect(ConstantsDemo::GEN_WHAT[35]).to be_a(Thrift::Struct)
|
|
96
|
-
expect(ConstantsDemo::GEN_WHAT[35].hello).to eq(325)
|
|
97
|
-
expect(ConstantsDemo::GEN_WHAT[35].goodbye).to eq(325352)
|
|
98
|
-
expect(ConstantsDemo::GEN_WHAT[35].id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
99
|
-
expect(ConstantsDemo::GEN_WHAT[35].my_id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
100
|
-
expect(ConstantsDemo::GEN_WHAT[35].my_optional_id).to eq("00000000-4444-CCCC-ffff-0123456789ab")
|
|
101
|
-
end
|
|
102
|
-
end
|