upfluence-thrift 2.6.8 → 2.7.4

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.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/benchmark/{gen-rb/benchmark_constants.rb → benchmark_constants.rb} +1 -1
  3. data/benchmark/{gen-rb/benchmark_service.rb → benchmark_service.rb} +2 -2
  4. data/benchmark/{gen-rb/benchmark_types.rb → benchmark_types.rb} +1 -1
  5. data/ext/struct.c +5 -1
  6. data/lib/thrift/base_stream.rb +85 -0
  7. data/lib/thrift/bidi_stream.rb +183 -0
  8. data/lib/thrift/client.rb +84 -17
  9. data/lib/thrift/inbound_stream.rb +72 -0
  10. data/lib/thrift/middleware.rb +42 -0
  11. data/lib/thrift/outbound_stream.rb +52 -0
  12. data/lib/thrift/processor.rb +287 -47
  13. data/lib/thrift/protocol/base_protocol.rb +35 -33
  14. data/lib/thrift/protocol/binary_protocol.rb +8 -1
  15. data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
  16. data/lib/thrift/protocol/compact_protocol.rb +8 -0
  17. data/lib/thrift/protocol/json_protocol.rb +21 -4
  18. data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
  19. data/lib/thrift/server/base_server.rb +8 -2
  20. data/lib/thrift/server/nonblocking_server.rb +5 -4
  21. data/lib/thrift/server/simple_server.rb +5 -1
  22. data/lib/thrift/server/thread_pool_server.rb +5 -1
  23. data/lib/thrift/server/threaded_server.rb +5 -1
  24. data/lib/thrift/transport/base_server_transport.rb +1 -1
  25. data/lib/thrift/transport/base_transport.rb +8 -0
  26. data/lib/thrift/transport/buffered_transport.rb +9 -1
  27. data/lib/thrift/transport/framed_transport.rb +9 -1
  28. data/lib/thrift/transport/http_client_transport.rb +4 -0
  29. data/lib/thrift/transport/io_stream_transport.rb +4 -1
  30. data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
  31. data/lib/thrift/transport/server_socket.rb +5 -0
  32. data/lib/thrift/transport/socket.rb +21 -17
  33. data/lib/thrift/transport/ssl_server_socket.rb +41 -0
  34. data/lib/thrift/transport/ssl_socket.rb +51 -0
  35. data/lib/thrift/transport/unix_server_socket.rb +5 -1
  36. data/lib/thrift/transport/unix_socket.rb +5 -1
  37. data/lib/thrift/types/annotation/deprecation/deprecation_constants.rb +1 -1
  38. data/lib/thrift/types/annotation/deprecation/deprecation_types.rb +2 -2
  39. data/lib/thrift/types/annotation/exception/exception_constants.rb +17 -0
  40. data/lib/thrift/types/annotation/exception/exception_types.rb +44 -0
  41. data/lib/thrift/types/annotation/naming/naming_constants.rb +1 -1
  42. data/lib/thrift/types/annotation/naming/naming_types.rb +2 -2
  43. data/lib/thrift/types/annotation/rpc/rpc_constants.rb +17 -0
  44. data/lib/thrift/types/annotation/rpc/rpc_types.rb +74 -0
  45. data/lib/thrift/types/annotation_definition/annotation_definition_constants.rb +15 -0
  46. data/lib/thrift/types/annotation_definition/annotation_definition_types.rb +116 -0
  47. data/lib/thrift/types/constant_definition/constant_definition_constants.rb +15 -0
  48. data/lib/thrift/types/constant_definition/constant_definition_types.rb +292 -0
  49. data/lib/thrift/types/core/core_constants.rb +15 -0
  50. data/lib/thrift/types/core/core_types.rb +58 -0
  51. data/lib/thrift/types/enum_definition/enum_definition_constants.rb +15 -0
  52. data/lib/thrift/types/enum_definition/enum_definition_types.rb +106 -0
  53. data/lib/thrift/types/known/any/any_constants.rb +1 -1
  54. data/lib/thrift/types/known/any/any_types.rb +2 -2
  55. data/lib/thrift/types/known/duration/duration_constants.rb +1 -1
  56. data/lib/thrift/types/known/duration/duration_types.rb +2 -2
  57. data/lib/thrift/types/known/timestamp/timestamp_constants.rb +1 -1
  58. data/lib/thrift/types/known/timestamp/timestamp_types.rb +2 -2
  59. data/lib/thrift/types/plugin/plugin.rb +139 -0
  60. data/lib/thrift/types/plugin/plugin_constants.rb +15 -0
  61. data/lib/thrift/types/plugin/plugin_types.rb +106 -0
  62. data/lib/thrift/types/program_definition/program_definition_constants.rb +15 -0
  63. data/lib/thrift/types/program_definition/program_definition_types.rb +137 -0
  64. data/lib/thrift/types/service_definition/service_definition_constants.rb +15 -0
  65. data/lib/thrift/types/service_definition/service_definition_types.rb +160 -0
  66. data/lib/thrift/types/struct_definition/struct_definition_constants.rb +15 -0
  67. data/lib/thrift/types/struct_definition/struct_definition_types.rb +157 -0
  68. data/lib/thrift/types/type_definition/type_definition_constants.rb +15 -0
  69. data/lib/thrift/types/type_definition/type_definition_types.rb +242 -0
  70. data/lib/thrift/types/value/value_constants.rb +1 -1
  71. data/lib/thrift/types/value/value_types.rb +50 -51
  72. data/lib/thrift/types.rb +11 -3
  73. data/lib/thrift/union.rb +3 -6
  74. data/lib/thrift.rb +6 -0
  75. data/lib/types/annotation/deprecation/deprecation_constants.rb +16 -0
  76. data/lib/types/annotation/deprecation/deprecation_types.rb +42 -0
  77. data/lib/types/annotation/naming/naming_constants.rb +16 -0
  78. data/lib/types/annotation/naming/naming_types.rb +57 -0
  79. data/lib/types/annotation_definition/annotation_definition_constants.rb +14 -0
  80. data/lib/types/annotation_definition/annotation_definition_types.rb +114 -0
  81. data/lib/types/constant_definition/constant_definition_constants.rb +14 -0
  82. data/lib/types/constant_definition/constant_definition_types.rb +290 -0
  83. data/lib/types/core/core_constants.rb +14 -0
  84. data/lib/types/core/core_types.rb +56 -0
  85. data/lib/types/enum_definition/enum_definition_constants.rb +14 -0
  86. data/lib/types/enum_definition/enum_definition_types.rb +104 -0
  87. data/lib/types/known/any/any_constants.rb +16 -0
  88. data/lib/types/known/any/any_types.rb +59 -0
  89. data/lib/types/known/duration/duration_constants.rb +16 -0
  90. data/lib/types/known/duration/duration_types.rb +59 -0
  91. data/lib/types/known/timestamp/timestamp_constants.rb +16 -0
  92. data/lib/types/known/timestamp/timestamp_types.rb +59 -0
  93. data/lib/types/plugin/plugin.rb +137 -0
  94. data/lib/types/plugin/plugin_constants.rb +14 -0
  95. data/lib/types/plugin/plugin_types.rb +104 -0
  96. data/lib/types/program_definition/program_definition_constants.rb +14 -0
  97. data/lib/types/program_definition/program_definition_types.rb +135 -0
  98. data/lib/types/service_definition/service_definition_constants.rb +14 -0
  99. data/lib/types/service_definition/service_definition_types.rb +158 -0
  100. data/lib/types/struct_definition/struct_definition_constants.rb +14 -0
  101. data/lib/types/struct_definition/struct_definition_types.rb +155 -0
  102. data/lib/types/type_definition/type_definition_constants.rb +14 -0
  103. data/lib/types/type_definition/type_definition_types.rb +240 -0
  104. data/lib/types/value/value_constants.rb +14 -0
  105. data/lib/types/value/value_types.rb +330 -0
  106. data/spec/{gen-rb/base → base}/base_service.rb +2 -2
  107. data/spec/{gen-rb/base → base}/base_service_constants.rb +1 -1
  108. data/spec/{gen-rb/base → base}/base_service_types.rb +1 -1
  109. data/spec/base_protocol_spec.rb +79 -71
  110. data/spec/base_transport_spec.rb +155 -117
  111. data/spec/binary_protocol_accelerated_spec.rb +6 -2
  112. data/spec/binary_protocol_spec.rb +16 -8
  113. data/spec/binary_protocol_spec_shared.rb +77 -77
  114. data/spec/bytes_spec.rb +38 -38
  115. data/spec/client_spec.rb +48 -50
  116. data/spec/compact_protocol_spec.rb +59 -46
  117. data/spec/exception_spec.rb +54 -54
  118. data/spec/{gen-rb/extended → extended}/extended_service.rb +2 -2
  119. data/spec/{gen-rb/extended → extended}/extended_service_constants.rb +1 -1
  120. data/spec/{gen-rb/extended → extended}/extended_service_types.rb +1 -1
  121. data/spec/flat_spec.rb +5 -5
  122. data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +4 -4
  123. data/spec/gen-rb/flat/referenced_constants.rb +1 -1
  124. data/spec/gen-rb/flat/referenced_types.rb +1 -1
  125. data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +1 -1
  126. data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +1 -1
  127. data/spec/http_client_spec.rb +96 -43
  128. data/spec/json_protocol_spec.rb +170 -131
  129. data/spec/namespaced_spec.rb +24 -27
  130. data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/namespaced_nonblocking_service.rb +4 -4
  131. data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/thrift_namespaced_spec_constants.rb +1 -1
  132. data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/thrift_namespaced_spec_types.rb +1 -1
  133. data/spec/nonblocking_server_spec.rb +16 -16
  134. data/spec/{gen-rb/nonblocking_service.rb → nonblocking_service.rb} +4 -4
  135. data/spec/{gen-rb/other_namespace → other_namespace}/referenced_constants.rb +1 -1
  136. data/spec/{gen-rb/other_namespace → other_namespace}/referenced_types.rb +1 -1
  137. data/spec/processor_spec.rb +42 -31
  138. data/spec/rack_application_spec.rb +22 -26
  139. data/spec/serializer_spec.rb +20 -20
  140. data/spec/server_socket_spec.rb +27 -22
  141. data/spec/server_spec.rb +91 -51
  142. data/spec/socket_spec.rb +23 -16
  143. data/spec/socket_spec_shared.rb +31 -31
  144. data/spec/spec_helper.rb +1 -1
  145. data/spec/ssl_server_socket_spec.rb +34 -0
  146. data/spec/ssl_socket_spec.rb +78 -0
  147. data/spec/streaming_spec.rb +442 -0
  148. data/spec/struct_nested_containers_spec.rb +24 -24
  149. data/spec/struct_spec.rb +120 -120
  150. data/spec/thin_http_server_spec.rb +71 -28
  151. data/spec/{gen-rb/thrift_spec_constants.rb → thrift_spec_constants.rb} +1 -1
  152. data/spec/{gen-rb/thrift_spec_types.rb → thrift_spec_types.rb} +16 -16
  153. data/spec/types/known/any_spec.rb +2 -2
  154. data/spec/types/known/duration_spec.rb +1 -1
  155. data/spec/types/known/timestamp_spec.rb +1 -1
  156. data/spec/types/value_spec.rb +2 -1
  157. data/spec/types_spec.rb +56 -53
  158. data/spec/union_spec.rb +51 -40
  159. data/spec/unix_socket_spec.rb +43 -34
  160. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +267 -260
  161. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +1481 -1416
  162. data/test/debug_proto/gen-rb/empty_service.rb +31 -27
  163. data/test/debug_proto/gen-rb/inherited.rb +102 -98
  164. data/test/debug_proto/gen-rb/reverse_order_service.rb +112 -108
  165. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +99 -95
  166. data/test/debug_proto/gen-rb/srv.rb +525 -406
  167. metadata +178 -41
data/spec/client_spec.rb CHANGED
@@ -20,80 +20,78 @@
20
20
  require 'spec_helper'
21
21
 
22
22
  describe 'Client' do
23
-
24
23
  class ClientSpec
25
24
  include Thrift::Client
26
25
  end
27
26
 
28
27
  before(:each) do
29
- @prot = mock("MockProtocol")
28
+ @prot = double('MockProtocol')
30
29
  @client = ClientSpec.new(@prot)
31
30
  end
32
31
 
33
32
  describe Thrift::Client do
34
- it "should re-use iprot for oprot if not otherwise specified" do
35
- @client.instance_variable_get(:'@iprot').should eql(@prot)
36
- @client.instance_variable_get(:'@oprot').should eql(@prot)
33
+ it 'should re-use iprot for oprot if not otherwise specified' do
34
+ expect(@client.instance_variable_get(:@iprot)).to eql(@prot)
35
+ expect(@client.instance_variable_get(:@oprot)).to eql(@prot)
37
36
  end
38
37
 
39
- it "should send a test message" do
40
- @prot.should_receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 1)
41
- mock_args = mock('#<TestMessage_args:mock>')
42
- mock_args.should_receive(:foo=).with('foo')
43
- mock_args.should_receive(:bar=).with(42)
44
- mock_args.should_receive(:write).with(@prot)
45
- @prot.should_receive(:write_message_end)
46
- @prot.should_receive(:trans) do
47
- mock('trans').tap do |trans|
48
- trans.should_receive(:flush)
38
+ it 'should send a test message' do
39
+ expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 1)
40
+ mock_args = double('#<TestMessage_args:mock>')
41
+ expect(mock_args).to receive(:foo=).with('foo')
42
+ expect(mock_args).to receive(:bar=).with(42)
43
+ expect(mock_args).to receive(:write).with(@prot)
44
+ expect(@prot).to receive(:write_message_end)
45
+ expect(@prot).to receive(:trans) do
46
+ double('trans').tap do |trans|
47
+ expect(trans).to receive(:flush)
49
48
  end
50
49
  end
51
- klass = stub("TestMessage_args", :new => mock_args)
52
- @client.send_message('testMessage', klass, :foo => 'foo', :bar => 42)
50
+ klass = double('TestMessage_args', new: mock_args)
51
+ @client.send_message('testMessage', klass, foo: 'foo', bar: 42)
53
52
  end
54
53
 
55
- it "should increment the sequence id when sending messages" do
56
- pending "it seems sequence ids are completely ignored right now" do
57
- @prot.should_receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 0).ordered
58
- @prot.should_receive(:write_message_begin).with('testMessage2', Thrift::MessageTypes::CALL, 1).ordered
59
- @prot.should_receive(:write_message_begin).with('testMessage3', Thrift::MessageTypes::CALL, 2).ordered
60
- @prot.stub!(:write_message_end)
61
- @prot.stub!(:trans).and_return mock("trans").as_null_object
62
- @client.send_message('testMessage', mock("args class").as_null_object)
63
- @client.send_message('testMessage2', mock("args class").as_null_object)
64
- @client.send_message('testMessage3', mock("args class").as_null_object)
65
- end
54
+ it 'should increment the sequence id when sending messages' do
55
+ pending 'it seems sequence ids are completely ignored right now'
56
+ @prot.expect(:write_message_begin).with('testMessage', Thrift::MessageTypes::CALL, 0).ordered
57
+ @prot.expect(:write_message_begin).with('testMessage2', Thrift::MessageTypes::CALL, 1).ordered
58
+ @prot.expect(:write_message_begin).with('testMessage3', Thrift::MessageTypes::CALL, 2).ordered
59
+ @prot.stub!(:write_message_end)
60
+ @prot.stub!(:trans).and_return double('trans').as_null_object
61
+ @client.send_message('testMessage', double('args class').as_null_object)
62
+ @client.send_message('testMessage2', double('args class').as_null_object)
63
+ @client.send_message('testMessage3', double('args class').as_null_object)
66
64
  end
67
65
 
68
- it "should receive a test message" do
69
- @prot.should_receive(:read_message_begin).and_return [nil, Thrift::MessageTypes::REPLY, 0]
70
- @prot.should_receive(:read_message_end)
71
- mock_klass = mock("#<MockClass:mock>")
72
- mock_klass.should_receive(:read).with(@prot)
73
- @client.receive_message(stub("MockClass", :new => mock_klass))
66
+ it 'should receive a test message' do
67
+ expect(@prot).to receive(:read_message_begin).and_return [nil, Thrift::MessageTypes::REPLY, 0]
68
+ expect(@prot).to receive(:read_message_end)
69
+ mock_klass = double('#<MockClass:mock>')
70
+ expect(mock_klass).to receive(:read).with(@prot)
71
+ @client.receive_message(double('MockClass', new: mock_klass))
74
72
  end
75
73
 
76
- it "should handle received exceptions" do
77
- @prot.should_receive(:read_message_begin).and_return [nil, Thrift::MessageTypes::EXCEPTION, 0]
78
- @prot.should_receive(:read_message_end)
79
- Thrift::ApplicationException.should_receive(:new).and_return do
74
+ it 'should handle received exceptions' do
75
+ expect(@prot).to receive(:read_message_begin).and_return [nil, Thrift::MessageTypes::EXCEPTION, 0]
76
+ expect(@prot).to receive(:read_message_end)
77
+ expect(Thrift::ApplicationException).to receive(:new) do
80
78
  StandardError.new.tap do |mock_exc|
81
- mock_exc.should_receive(:read).with(@prot)
79
+ expect(mock_exc).to receive(:read).with(@prot)
82
80
  end
83
81
  end
84
- lambda { @client.receive_message(nil) }.should raise_error(StandardError)
82
+ expect { @client.receive_message(nil) }.to raise_error(StandardError)
85
83
  end
86
84
 
87
- it "should close the transport if an error occurs while sending a message" do
88
- @prot.stub!(:write_message_begin)
89
- @prot.should_not_receive(:write_message_end)
90
- mock_args = mock("#<TestMessage_args:mock>")
91
- mock_args.should_receive(:write).with(@prot).and_raise(StandardError)
92
- trans = mock("MockTransport")
93
- @prot.stub!(:trans).and_return(trans)
94
- trans.should_receive(:close)
95
- klass = mock("TestMessage_args", :new => mock_args)
96
- lambda { @client.send_message("testMessage", klass) }.should raise_error(StandardError)
85
+ it 'should close the transport if an error occurs while sending a message' do
86
+ allow(@prot).to receive(:write_message_begin)
87
+ expect(@prot).not_to receive(:write_message_end)
88
+ mock_args = double('#<TestMessage_args:mock>')
89
+ expect(mock_args).to receive(:write).with(@prot).and_raise(StandardError)
90
+ trans = double('MockTransport')
91
+ allow(@prot).to receive(:trans).and_return(trans)
92
+ expect(trans).to receive(:close)
93
+ klass = double('TestMessage_args', new: mock_args)
94
+ expect { @client.send_message('testMessage', klass) }.to raise_error(StandardError)
97
95
  end
98
96
  end
99
97
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  #
3
2
  # Licensed to the Apache Software Foundation (ASF) under one
4
3
  # or more contributor license agreements. See the NOTICE file
@@ -22,17 +21,18 @@ require 'spec_helper'
22
21
 
23
22
  describe Thrift::CompactProtocol do
24
23
  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]
24
+ byte: (-127..127).to_a,
25
+ i16: (0..14).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
26
+ i32: (0..30).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
27
+ i64: (0..62).map { |shift| [1 << shift, -(1 << shift)] }.flatten.sort,
28
+ string: ['', '1', 'short', 'fourteen123456', 'fifteen12345678', "unicode characters: \u20AC \u20AD", '1' * 127,
29
+ '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, 10_000_000.1, 1.0 / 0.0, -1.0 / 0.0],
32
+ bool: [true, false]
33
33
  }
34
34
 
35
- it "should encode and decode naked primitives correctly" do
35
+ it 'should encode and decode naked primitives correctly' do
36
36
  TESTS.each_pair do |primitive_type, test_values|
37
37
  test_values.each do |value|
38
38
  # puts "testing #{value}" if primitive_type == :i64
@@ -42,12 +42,12 @@ describe Thrift::CompactProtocol do
42
42
  proto.send(writer(primitive_type), value)
43
43
  # puts "buf: #{trans.inspect_buffer}" if primitive_type == :i64
44
44
  read_back = proto.send(reader(primitive_type))
45
- read_back.should == value
45
+ expect(read_back).to eq(value)
46
46
  end
47
47
  end
48
48
  end
49
49
 
50
- it "should encode and decode primitives in fields correctly" do
50
+ it 'should encode and decode primitives in fields correctly' do
51
51
  TESTS.each_pair do |primitive_type, test_values|
52
52
  final_primitive_type = primitive_type == :binary ? :string : primitive_type
53
53
  thrift_type = Thrift::Types.const_get(final_primitive_type.to_s.upcase)
@@ -61,30 +61,30 @@ describe Thrift::CompactProtocol do
61
61
  proto.write_field_end
62
62
 
63
63
  proto = Thrift::CompactProtocol.new(trans)
64
- name, type, id = proto.read_field_begin
65
- type.should == thrift_type
66
- id.should == 15
64
+ _, type, id = proto.read_field_begin
65
+ expect(type).to eq(thrift_type)
66
+ expect(id).to eq(15)
67
67
  read_back = proto.send(reader(primitive_type))
68
- read_back.should == value
68
+ expect(read_back).to eq(value)
69
69
  proto.read_field_end
70
70
  end
71
71
  end
72
72
  end
73
73
 
74
- it "should encode and decode a monster struct correctly" do
74
+ it 'should encode and decode a monster struct correctly' do
75
75
  trans = Thrift::MemoryBufferTransport.new
76
76
  proto = Thrift::CompactProtocol.new(trans)
77
77
 
78
- struct = CompactProtoTestStruct.new
78
+ struct = Thrift::Test::CompactProtoTestStruct.new
79
79
  # sets and maps don't hash well... not sure what to do here.
80
80
  struct.write(proto)
81
81
 
82
- struct2 = CompactProtoTestStruct.new
82
+ struct2 = Thrift::Test::CompactProtoTestStruct.new
83
83
  struct2.read(proto)
84
- struct2.should == struct
84
+ expect(struct2).to eq(struct)
85
85
  end
86
86
 
87
- xit "should make method calls correctly" do
87
+ xit 'should make method calls correctly' do
88
88
  r1, w1 = IO.pipe
89
89
  r2, w2 = IO.pipe
90
90
  client_out_trans = Thrift::IOStreamTransport.new(r2, w1)
@@ -93,44 +93,47 @@ describe Thrift::CompactProtocol do
93
93
  client_in_trans = Thrift::IOStreamTransport.new(r1, w2)
94
94
  client_in_proto = Thrift::CompactProtocol.new(client_in_trans)
95
95
 
96
- processor = Srv::Processor.new(JankyHandler.new)
96
+ processor = Thrift::Test::Srv::Processor.new(JankyHandler.new)
97
97
 
98
- client = Srv::Client.new(
99
- Thrift::BaseClient.new(client_in_proto, client_out_proto)
100
- )
101
-
102
- t = Thread.new { processor.process(client_in_proto, client_out_proto) }
103
-
104
- client.Janky(1).should == 2
105
-
106
- t.join
98
+ client = Thrift::Test::Srv::Client.new(client_in_proto)
99
+ client.send_Janky(1)
100
+ # puts client_out_trans.inspect_buffer
101
+ processor.process(client_out_proto, client_in_proto)
102
+ expect(client.recv_Janky).to eq(2)
107
103
  end
108
104
 
109
- it "should deal with fields following fields that have non-delta ids" do
110
- brcp = BreaksRubyCompactProtocol.new(
111
- :field1 => "blah",
112
- :field2 => BigFieldIdStruct.new(
113
- :field1 => "string1",
114
- :field2 => "string2"),
115
- :field3 => 3)
105
+ it 'should deal with fields following fields that have non-delta ids' do
106
+ brcp = Thrift::Test::BreaksRubyCompactProtocol.new(
107
+ field1: 'blah',
108
+ field2: Thrift::Test::BigFieldIdStruct.new(
109
+ field1: 'string1',
110
+ field2: 'string2'
111
+ ),
112
+ field3: 3
113
+ )
116
114
  ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
117
115
  bytes = ser.serialize(brcp)
118
116
 
119
117
  deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
120
- brcp2 = BreaksRubyCompactProtocol.new
118
+ brcp2 = Thrift::Test::BreaksRubyCompactProtocol.new
121
119
  deser.deserialize(brcp2, bytes)
122
- brcp2.should == brcp
120
+ expect(brcp2).to eq(brcp)
123
121
  end
124
122
 
125
- it "should deserialize an empty map to an empty hash" do
126
- struct = SingleMapTestStruct.new(:i32_map => {})
123
+ it 'should deserialize an empty map to an empty hash' do
124
+ struct = Thrift::Test::SingleMapTestStruct.new(i32_map: {})
127
125
  ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
128
126
  bytes = ser.serialize(struct)
129
127
 
130
128
  deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
131
- struct2 = SingleMapTestStruct.new
129
+ struct2 = Thrift::Test::SingleMapTestStruct.new
132
130
  deser.deserialize(struct2, bytes)
133
- struct.should == struct2
131
+ expect(struct).to eq(struct2)
132
+ end
133
+
134
+ it 'should provide a reasonable to_s' do
135
+ trans = Thrift::MemoryBufferTransport.new
136
+ expect(Thrift::CompactProtocol.new(trans).to_s).to eq('compact(memory)')
134
137
  end
135
138
 
136
139
  class JankyHandler
@@ -140,10 +143,20 @@ describe Thrift::CompactProtocol do
140
143
  end
141
144
 
142
145
  def writer(sym)
143
- "write_#{sym.to_s}"
146
+ "write_#{sym}"
144
147
  end
145
148
 
146
149
  def reader(sym)
147
- "read_#{sym.to_s}"
150
+ "read_#{sym}"
151
+ end
152
+ end
153
+
154
+ describe Thrift::CompactProtocolFactory do
155
+ it 'should create a CompactProtocol' do
156
+ expect(Thrift::CompactProtocolFactory.new.get_protocol(double('MockTransport'))).to be_instance_of(Thrift::CompactProtocol)
157
+ end
158
+
159
+ it 'should provide a reasonable to_s' do
160
+ expect(Thrift::CompactProtocolFactory.new.to_s).to eq('compact')
148
161
  end
149
162
  end
@@ -24,107 +24,107 @@ describe 'Exception' do
24
24
  describe Thrift::Exception do
25
25
  it "should have an accessible message" do
26
26
  e = Thrift::Exception.new("test message")
27
- e.message.should == "test message"
27
+ expect(e.message).to eq("test message")
28
28
  end
29
29
  end
30
30
 
31
31
  describe Thrift::ApplicationException do
32
32
  it "should inherit from Thrift::Exception" do
33
- Thrift::ApplicationException.superclass.should == Thrift::Exception
33
+ expect(Thrift::ApplicationException.superclass).to eq(Thrift::Exception)
34
34
  end
35
35
 
36
36
  it "should have an accessible type and message" do
37
37
  e = Thrift::ApplicationException.new
38
- e.type.should == Thrift::ApplicationException::UNKNOWN
39
- e.message.should be_nil
38
+ expect(e.type).to eq(Thrift::ApplicationException::UNKNOWN)
39
+ expect(e.message).to be_nil
40
40
  e = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, "test message")
41
- e.type.should == Thrift::ApplicationException::UNKNOWN_METHOD
42
- e.message.should == "test message"
41
+ expect(e.type).to eq(Thrift::ApplicationException::UNKNOWN_METHOD)
42
+ expect(e.message).to eq("test message")
43
43
  end
44
44
 
45
45
  it "should read a struct off of a protocol" do
46
- prot = mock("MockProtocol")
47
- prot.should_receive(:read_struct_begin).ordered
48
- prot.should_receive(:read_field_begin).exactly(3).times.and_return(
46
+ prot = double("MockProtocol")
47
+ expect(prot).to receive(:read_struct_begin).ordered
48
+ expect(prot).to receive(:read_field_begin).exactly(3).times.and_return(
49
49
  ["message", Thrift::Types::STRING, 1],
50
50
  ["type", Thrift::Types::I32, 2],
51
51
  [nil, Thrift::Types::STOP, 0]
52
52
  )
53
- prot.should_receive(:read_string).ordered.and_return "test message"
54
- prot.should_receive(:read_i32).ordered.and_return Thrift::ApplicationException::BAD_SEQUENCE_ID
55
- prot.should_receive(:read_field_end).exactly(2).times
56
- prot.should_receive(:read_struct_end).ordered
53
+ expect(prot).to receive(:read_string).ordered.and_return "test message"
54
+ expect(prot).to receive(:read_i32).ordered.and_return Thrift::ApplicationException::BAD_SEQUENCE_ID
55
+ expect(prot).to receive(:read_field_end).exactly(2).times
56
+ expect(prot).to receive(:read_struct_end).ordered
57
57
 
58
58
  e = Thrift::ApplicationException.new
59
59
  e.read(prot)
60
- e.message.should == "test message"
61
- e.type.should == Thrift::ApplicationException::BAD_SEQUENCE_ID
60
+ expect(e.message).to eq("test message")
61
+ expect(e.type).to eq(Thrift::ApplicationException::BAD_SEQUENCE_ID)
62
62
  end
63
63
 
64
64
  it "should skip bad fields when reading a struct" do
65
- prot = mock("MockProtocol")
66
- prot.should_receive(:read_struct_begin).ordered
67
- prot.should_receive(:read_field_begin).exactly(5).times.and_return(
65
+ prot = double("MockProtocol")
66
+ expect(prot).to receive(:read_struct_begin).ordered
67
+ expect(prot).to receive(:read_field_begin).exactly(5).times.and_return(
68
68
  ["type", Thrift::Types::I32, 2],
69
69
  ["type", Thrift::Types::STRING, 2],
70
70
  ["message", Thrift::Types::MAP, 1],
71
71
  ["message", Thrift::Types::STRING, 3],
72
72
  [nil, Thrift::Types::STOP, 0]
73
73
  )
74
- prot.should_receive(:read_i32).and_return Thrift::ApplicationException::INVALID_MESSAGE_TYPE
75
- prot.should_receive(:skip).with(Thrift::Types::STRING).twice
76
- prot.should_receive(:skip).with(Thrift::Types::MAP)
77
- prot.should_receive(:read_field_end).exactly(4).times
78
- prot.should_receive(:read_struct_end).ordered
74
+ expect(prot).to receive(:read_i32).and_return Thrift::ApplicationException::INVALID_MESSAGE_TYPE
75
+ expect(prot).to receive(:skip).with(Thrift::Types::STRING).twice
76
+ expect(prot).to receive(:skip).with(Thrift::Types::MAP)
77
+ expect(prot).to receive(:read_field_end).exactly(4).times
78
+ expect(prot).to receive(:read_struct_end).ordered
79
79
 
80
80
  e = Thrift::ApplicationException.new
81
81
  e.read(prot)
82
- e.message.should be_nil
83
- e.type.should == Thrift::ApplicationException::INVALID_MESSAGE_TYPE
82
+ expect(e.message).to be_nil
83
+ expect(e.type).to eq(Thrift::ApplicationException::INVALID_MESSAGE_TYPE)
84
84
  end
85
85
 
86
86
  it "should write a Thrift::ApplicationException struct to the oprot" do
87
- prot = mock("MockProtocol")
88
- prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
89
- prot.should_receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
90
- prot.should_receive(:write_string).with("test message").ordered
91
- prot.should_receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
92
- prot.should_receive(:write_i32).with(Thrift::ApplicationException::UNKNOWN_METHOD).ordered
93
- prot.should_receive(:write_field_end).twice
94
- prot.should_receive(:write_field_stop).ordered
95
- prot.should_receive(:write_struct_end).ordered
87
+ prot = double("MockProtocol")
88
+ expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
89
+ expect(prot).to receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
90
+ expect(prot).to receive(:write_string).with("test message").ordered
91
+ expect(prot).to receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
92
+ expect(prot).to receive(:write_i32).with(Thrift::ApplicationException::UNKNOWN_METHOD).ordered
93
+ expect(prot).to receive(:write_field_end).twice
94
+ expect(prot).to receive(:write_field_stop).ordered
95
+ expect(prot).to receive(:write_struct_end).ordered
96
96
 
97
97
  e = Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, "test message")
98
98
  e.write(prot)
99
99
  end
100
100
 
101
101
  it "should skip nil fields when writing to the oprot" do
102
- prot = mock("MockProtocol")
103
- prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
104
- prot.should_receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
105
- prot.should_receive(:write_string).with("test message").ordered
106
- prot.should_receive(:write_field_end).ordered
107
- prot.should_receive(:write_field_stop).ordered
108
- prot.should_receive(:write_struct_end).ordered
102
+ prot = double("MockProtocol")
103
+ expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
104
+ expect(prot).to receive(:write_field_begin).with("message", Thrift::Types::STRING, 1).ordered
105
+ expect(prot).to receive(:write_string).with("test message").ordered
106
+ expect(prot).to receive(:write_field_end).ordered
107
+ expect(prot).to receive(:write_field_stop).ordered
108
+ expect(prot).to receive(:write_struct_end).ordered
109
109
 
110
110
  e = Thrift::ApplicationException.new(nil, "test message")
111
111
  e.write(prot)
112
112
 
113
- prot = mock("MockProtocol")
114
- prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
115
- prot.should_receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
116
- prot.should_receive(:write_i32).with(Thrift::ApplicationException::BAD_SEQUENCE_ID).ordered
117
- prot.should_receive(:write_field_end).ordered
118
- prot.should_receive(:write_field_stop).ordered
119
- prot.should_receive(:write_struct_end).ordered
113
+ prot = double("MockProtocol")
114
+ expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
115
+ expect(prot).to receive(:write_field_begin).with("type", Thrift::Types::I32, 2).ordered
116
+ expect(prot).to receive(:write_i32).with(Thrift::ApplicationException::BAD_SEQUENCE_ID).ordered
117
+ expect(prot).to receive(:write_field_end).ordered
118
+ expect(prot).to receive(:write_field_stop).ordered
119
+ expect(prot).to receive(:write_struct_end).ordered
120
120
 
121
121
  e = Thrift::ApplicationException.new(Thrift::ApplicationException::BAD_SEQUENCE_ID)
122
122
  e.write(prot)
123
123
 
124
- prot = mock("MockProtocol")
125
- prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
126
- prot.should_receive(:write_field_stop).ordered
127
- prot.should_receive(:write_struct_end).ordered
124
+ prot = double("MockProtocol")
125
+ expect(prot).to receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
126
+ expect(prot).to receive(:write_field_stop).ordered
127
+ expect(prot).to receive(:write_struct_end).ordered
128
128
 
129
129
  e = Thrift::ApplicationException.new(nil)
130
130
  e.write(prot)
@@ -134,8 +134,8 @@ describe 'Exception' do
134
134
  describe Thrift::ProtocolException do
135
135
  it "should have an accessible type" do
136
136
  prot = Thrift::ProtocolException.new(Thrift::ProtocolException::SIZE_LIMIT, "message")
137
- prot.type.should == Thrift::ProtocolException::SIZE_LIMIT
138
- prot.message.should == "message"
137
+ expect(prot.type).to eq(Thrift::ProtocolException::SIZE_LIMIT)
138
+ expect(prot.message).to eq("message")
139
139
  end
140
140
  end
141
141
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler ()
2
+ # Autogenerated by Thrift Compiler (v0.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -108,7 +108,7 @@ module Extended
108
108
  ].freeze
109
109
 
110
110
  METHODS = {
111
- 'ping' => { args_klass: Ping_args, oneway: false, legacy_annotations: THRIFT_METHOD_PING_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_PING_STRUCTURED_ANNOTATIONS},
111
+ 'ping' => { args_klass: Ping_args, result_klass: Ping_result, oneway: false, legacy_annotations: THRIFT_METHOD_PING_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_PING_STRUCTURED_ANNOTATIONS},
112
112
  }.freeze
113
113
 
114
114
  def execute_ping(args)
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler ()
2
+ # Autogenerated by Thrift Compiler (v0.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler ()
2
+ # Autogenerated by Thrift Compiler (v0.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
data/spec/flat_spec.rb CHANGED
@@ -32,7 +32,7 @@ describe 'generation' do
32
32
  "other_namespace/referenced_constants.rb",
33
33
  "other_namespace/referenced_types.rb"
34
34
  ].each do |name|
35
- File.exist?(File.join(prefix, name)).should_not be_true
35
+ expect(File.exist?(File.join(prefix, name))).not_to be_truthy
36
36
  end
37
37
  end
38
38
 
@@ -44,19 +44,19 @@ describe 'generation' do
44
44
  "referenced_constants.rb",
45
45
  "referenced_types.rb"
46
46
  ].each do |name|
47
- File.exist?(File.join(prefix, name)).should be_true
47
+ expect(File.exist?(File.join(prefix, name))).to be_truthy
48
48
  end
49
49
  end
50
50
 
51
51
  it "has a service class in the right place" do
52
- defined?(NamespacedSpecNamespace::NamespacedNonblockingService).should be_true
52
+ expect(defined?(NamespacedSpecNamespace::NamespacedNonblockingService)).to be_truthy
53
53
  end
54
54
 
55
55
  it "has a struct in the right place" do
56
- defined?(NamespacedSpecNamespace::Hello).should be_true
56
+ expect(defined?(NamespacedSpecNamespace::Hello)).to be_truthy
57
57
  end
58
58
 
59
59
  it "required an included file" do
60
- defined?(OtherNamespace::SomeEnum).should be_true
60
+ expect(defined?(OtherNamespace::SomeEnum)).to be_truthy
61
61
  end
62
62
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler ()
2
+ # Autogenerated by Thrift Compiler (v0.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -412,11 +412,11 @@ module NamespacedSpecNamespace
412
412
  ].freeze
413
413
 
414
414
  METHODS = {
415
- 'greeting' => { args_klass: Greeting_args, oneway: false, legacy_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS},
416
- 'block' => { args_klass: Block_args, oneway: false, legacy_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS},
415
+ 'greeting' => { args_klass: Greeting_args, result_klass: Greeting_result, oneway: false, legacy_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS},
416
+ 'block' => { args_klass: Block_args, result_klass: Block_result, oneway: false, legacy_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS},
417
417
  'unblock' => { args_klass: Unblock_args, oneway: true, legacy_annotations: THRIFT_METHOD_UNBLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_UNBLOCK_STRUCTURED_ANNOTATIONS},
418
418
  'shutdown' => { args_klass: Shutdown_args, oneway: true, legacy_annotations: THRIFT_METHOD_SHUTDOWN_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SHUTDOWN_STRUCTURED_ANNOTATIONS},
419
- 'sleep' => { args_klass: Sleep_args, oneway: false, legacy_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS},
419
+ 'sleep' => { args_klass: Sleep_args, result_klass: Sleep_result, oneway: false, legacy_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS},
420
420
  }.freeze
421
421
 
422
422
  def execute_greeting(args)
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler ()
2
+ # Autogenerated by Thrift Compiler (v0.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler ()
2
+ # Autogenerated by Thrift Compiler (v0.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler ()
2
+ # Autogenerated by Thrift Compiler (v0.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler ()
2
+ # Autogenerated by Thrift Compiler (v0.0.1-upfluence)
3
3
  #
4
4
  # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
5
  #