thrift-mavericks 0.8.0 → 0.9.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +8 -8
  2. data/ext/binary_protocol_accelerated.c +21 -2
  3. data/ext/bytes.c +36 -0
  4. data/ext/bytes.h +31 -0
  5. data/ext/compact_protocol.c +24 -7
  6. data/ext/constants.h +5 -5
  7. data/ext/extconf.rb +3 -1
  8. data/ext/memory_buffer.c +11 -8
  9. data/ext/protocol.c +0 -185
  10. data/ext/protocol.h +0 -20
  11. data/ext/struct.c +0 -3
  12. data/ext/thrift_native.c +10 -11
  13. data/lib/thrift.rb +3 -0
  14. data/lib/thrift/bytes.rb +131 -0
  15. data/lib/thrift/exceptions.rb +3 -0
  16. data/lib/thrift/protocol/base_protocol.rb +96 -9
  17. data/lib/thrift/protocol/binary_protocol.rb +15 -7
  18. data/lib/thrift/protocol/compact_protocol.rb +14 -6
  19. data/lib/thrift/protocol/json_protocol.rb +766 -0
  20. data/lib/thrift/server/mongrel_http_server.rb +2 -0
  21. data/lib/thrift/server/thin_http_server.rb +91 -0
  22. data/lib/thrift/struct.rb +1 -1
  23. data/lib/thrift/struct_union.rb +2 -2
  24. data/lib/thrift/transport/base_transport.rb +22 -20
  25. data/lib/thrift/transport/buffered_transport.rb +16 -10
  26. data/lib/thrift/transport/framed_transport.rb +11 -10
  27. data/lib/thrift/transport/http_client_transport.rb +11 -6
  28. data/lib/thrift/transport/io_stream_transport.rb +1 -1
  29. data/lib/thrift/transport/memory_buffer_transport.rb +6 -6
  30. data/lib/thrift/transport/socket.rb +4 -2
  31. data/spec/ThriftSpec.thrift +52 -1
  32. data/spec/base_protocol_spec.rb +108 -51
  33. data/spec/base_transport_spec.rb +49 -50
  34. data/spec/binary_protocol_accelerated_spec.rb +9 -13
  35. data/spec/binary_protocol_spec.rb +15 -10
  36. data/spec/binary_protocol_spec_shared.rb +92 -12
  37. data/spec/bytes_spec.rb +160 -0
  38. data/spec/client_spec.rb +13 -14
  39. data/spec/compact_protocol_spec.rb +4 -5
  40. data/spec/exception_spec.rb +39 -40
  41. data/spec/gen-rb/thrift_spec_types.rb +192 -0
  42. data/spec/http_client_spec.rb +65 -9
  43. data/spec/json_protocol_spec.rb +513 -0
  44. data/spec/nonblocking_server_spec.rb +18 -20
  45. data/spec/processor_spec.rb +13 -16
  46. data/spec/serializer_spec.rb +17 -19
  47. data/spec/server_socket_spec.rb +6 -7
  48. data/spec/server_spec.rb +46 -58
  49. data/spec/socket_spec.rb +11 -11
  50. data/spec/socket_spec_shared.rb +1 -1
  51. data/spec/spec_helper.rb +13 -10
  52. data/spec/struct_nested_containers_spec.rb +191 -0
  53. data/spec/struct_spec.rb +84 -86
  54. data/spec/thin_http_server_spec.rb +140 -0
  55. data/spec/types_spec.rb +65 -66
  56. data/spec/union_spec.rb +57 -47
  57. data/spec/unix_socket_spec.rb +8 -9
  58. metadata +72 -14
  59. data/spec/mongrel_http_server_spec.rb +0 -117
@@ -17,16 +17,15 @@
17
17
  # under the License.
18
18
  #
19
19
 
20
- require File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
20
+ require 'spec_helper'
21
21
  require File.expand_path("#{File.dirname(__FILE__)}/socket_spec_shared")
22
22
 
23
- class ThriftUNIXSocketSpec < Spec::ExampleGroup
24
- include Thrift
23
+ describe 'UNIXSocket' do
25
24
 
26
- describe UNIXSocket do
25
+ describe Thrift::UNIXSocket do
27
26
  before(:each) do
28
27
  @path = '/tmp/thrift_spec_socket'
29
- @socket = UNIXSocket.new(@path)
28
+ @socket = Thrift::UNIXSocket.new(@path)
30
29
  @handle = mock("Handle", :closed? => false)
31
30
  @handle.stub!(:close)
32
31
  ::UNIXSocket.stub!(:new).and_return(@handle)
@@ -41,14 +40,14 @@ class ThriftUNIXSocketSpec < Spec::ExampleGroup
41
40
 
42
41
  it "should accept an optional timeout" do
43
42
  ::UNIXSocket.stub!(:new)
44
- UNIXSocket.new(@path, 5).timeout.should == 5
43
+ Thrift::UNIXSocket.new(@path, 5).timeout.should == 5
45
44
  end
46
45
  end
47
46
 
48
- describe UNIXServerSocket do
47
+ describe Thrift::UNIXServerSocket do
49
48
  before(:each) do
50
49
  @path = '/tmp/thrift_spec_socket'
51
- @socket = UNIXServerSocket.new(@path)
50
+ @socket = Thrift::UNIXServerSocket.new(@path)
52
51
  end
53
52
 
54
53
  it "should create a handle when calling listen" do
@@ -63,7 +62,7 @@ class ThriftUNIXSocketSpec < Spec::ExampleGroup
63
62
  sock = mock("sock")
64
63
  handle.should_receive(:accept).and_return(sock)
65
64
  trans = mock("UNIXSocket")
66
- UNIXSocket.should_receive(:new).and_return(trans)
65
+ Thrift::UNIXSocket.should_receive(:new).and_return(trans)
67
66
  trans.should_receive(:handle=).with(sock)
68
67
  @socket.accept.should == trans
69
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thrift-mavericks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thrift Developers
@@ -11,35 +11,77 @@ cert_chain: []
11
11
  date: 2013-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.10.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.10.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: rack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '='
45
+ - - ~>
32
46
  - !ruby/object:Gem::Version
33
- version: 1.3.2
47
+ version: 0.6.2
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '='
52
+ - - ~>
39
53
  - !ruby/object:Gem::Version
40
- version: 1.3.2
54
+ version: 0.6.2
41
55
  - !ruby/object:Gem::Dependency
42
- name: mongrel
56
+ name: thin
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.5.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.5.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
87
  - - ! '>='
@@ -62,6 +104,7 @@ extra_rdoc_files:
62
104
  - CHANGELOG
63
105
  - README
64
106
  - ext/binary_protocol_accelerated.c
107
+ - ext/bytes.c
65
108
  - ext/compact_protocol.c
66
109
  - ext/memory_buffer.c
67
110
  - ext/protocol.c
@@ -69,6 +112,7 @@ extra_rdoc_files:
69
112
  - ext/struct.c
70
113
  - ext/thrift_native.c
71
114
  - ext/binary_protocol_accelerated.h
115
+ - ext/bytes.h
72
116
  - ext/compact_protocol.h
73
117
  - ext/constants.h
74
118
  - ext/macros.h
@@ -77,6 +121,7 @@ extra_rdoc_files:
77
121
  - ext/strlcpy.h
78
122
  - ext/struct.h
79
123
  - ext/extconf.rb
124
+ - lib/thrift/bytes.rb
80
125
  - lib/thrift/client.rb
81
126
  - lib/thrift/core_ext/fixnum.rb
82
127
  - lib/thrift/core_ext.rb
@@ -86,12 +131,14 @@ extra_rdoc_files:
86
131
  - lib/thrift/protocol/binary_protocol.rb
87
132
  - lib/thrift/protocol/binary_protocol_accelerated.rb
88
133
  - lib/thrift/protocol/compact_protocol.rb
134
+ - lib/thrift/protocol/json_protocol.rb
89
135
  - lib/thrift/serializer/deserializer.rb
90
136
  - lib/thrift/serializer/serializer.rb
91
137
  - lib/thrift/server/base_server.rb
92
138
  - lib/thrift/server/mongrel_http_server.rb
93
139
  - lib/thrift/server/nonblocking_server.rb
94
140
  - lib/thrift/server/simple_server.rb
141
+ - lib/thrift/server/thin_http_server.rb
95
142
  - lib/thrift/server/thread_pool_server.rb
96
143
  - lib/thrift/server/threaded_server.rb
97
144
  - lib/thrift/struct.rb
@@ -112,6 +159,7 @@ extra_rdoc_files:
112
159
  - lib/thrift/union.rb
113
160
  - lib/thrift.rb
114
161
  files:
162
+ - lib/thrift/bytes.rb
115
163
  - lib/thrift/client.rb
116
164
  - lib/thrift/core_ext/fixnum.rb
117
165
  - lib/thrift/core_ext.rb
@@ -121,12 +169,14 @@ files:
121
169
  - lib/thrift/protocol/binary_protocol.rb
122
170
  - lib/thrift/protocol/binary_protocol_accelerated.rb
123
171
  - lib/thrift/protocol/compact_protocol.rb
172
+ - lib/thrift/protocol/json_protocol.rb
124
173
  - lib/thrift/serializer/deserializer.rb
125
174
  - lib/thrift/serializer/serializer.rb
126
175
  - lib/thrift/server/base_server.rb
127
176
  - lib/thrift/server/mongrel_http_server.rb
128
177
  - lib/thrift/server/nonblocking_server.rb
129
178
  - lib/thrift/server/simple_server.rb
179
+ - lib/thrift/server/thin_http_server.rb
130
180
  - lib/thrift/server/thread_pool_server.rb
131
181
  - lib/thrift/server/threaded_server.rb
132
182
  - lib/thrift/struct.rb
@@ -151,6 +201,7 @@ files:
151
201
  - spec/binary_protocol_accelerated_spec.rb
152
202
  - spec/binary_protocol_spec.rb
153
203
  - spec/binary_protocol_spec_shared.rb
204
+ - spec/bytes_spec.rb
154
205
  - spec/client_spec.rb
155
206
  - spec/compact_protocol_spec.rb
156
207
  - spec/exception_spec.rb
@@ -158,7 +209,7 @@ files:
158
209
  - spec/gen-rb/thrift_spec_constants.rb
159
210
  - spec/gen-rb/thrift_spec_types.rb
160
211
  - spec/http_client_spec.rb
161
- - spec/mongrel_http_server_spec.rb
212
+ - spec/json_protocol_spec.rb
162
213
  - spec/nonblocking_server_spec.rb
163
214
  - spec/processor_spec.rb
164
215
  - spec/serializer_spec.rb
@@ -167,7 +218,9 @@ files:
167
218
  - spec/socket_spec.rb
168
219
  - spec/socket_spec_shared.rb
169
220
  - spec/spec_helper.rb
221
+ - spec/struct_nested_containers_spec.rb
170
222
  - spec/struct_spec.rb
223
+ - spec/thin_http_server_spec.rb
171
224
  - spec/ThriftSpec.thrift
172
225
  - spec/types_spec.rb
173
226
  - spec/union_spec.rb
@@ -175,6 +228,7 @@ files:
175
228
  - CHANGELOG
176
229
  - README
177
230
  - ext/binary_protocol_accelerated.c
231
+ - ext/bytes.c
178
232
  - ext/compact_protocol.c
179
233
  - ext/memory_buffer.c
180
234
  - ext/protocol.c
@@ -182,6 +236,7 @@ files:
182
236
  - ext/struct.c
183
237
  - ext/thrift_native.c
184
238
  - ext/binary_protocol_accelerated.h
239
+ - ext/bytes.h
185
240
  - ext/compact_protocol.h
186
241
  - ext/constants.h
187
242
  - ext/macros.h
@@ -249,6 +304,7 @@ test_files:
249
304
  - spec/binary_protocol_accelerated_spec.rb
250
305
  - spec/binary_protocol_spec.rb
251
306
  - spec/binary_protocol_spec_shared.rb
307
+ - spec/bytes_spec.rb
252
308
  - spec/client_spec.rb
253
309
  - spec/compact_protocol_spec.rb
254
310
  - spec/exception_spec.rb
@@ -256,7 +312,7 @@ test_files:
256
312
  - spec/gen-rb/thrift_spec_constants.rb
257
313
  - spec/gen-rb/thrift_spec_types.rb
258
314
  - spec/http_client_spec.rb
259
- - spec/mongrel_http_server_spec.rb
315
+ - spec/json_protocol_spec.rb
260
316
  - spec/nonblocking_server_spec.rb
261
317
  - spec/processor_spec.rb
262
318
  - spec/serializer_spec.rb
@@ -265,7 +321,9 @@ test_files:
265
321
  - spec/socket_spec.rb
266
322
  - spec/socket_spec_shared.rb
267
323
  - spec/spec_helper.rb
324
+ - spec/struct_nested_containers_spec.rb
268
325
  - spec/struct_spec.rb
326
+ - spec/thin_http_server_spec.rb
269
327
  - spec/ThriftSpec.thrift
270
328
  - spec/types_spec.rb
271
329
  - spec/union_spec.rb
@@ -1,117 +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 File.expand_path("#{File.dirname(__FILE__)}/spec_helper")
21
- require 'thrift/server/mongrel_http_server'
22
-
23
- class ThriftHTTPServerSpec < Spec::ExampleGroup
24
- include Thrift
25
-
26
- Handler = MongrelHTTPServer::Handler
27
-
28
- describe MongrelHTTPServer do
29
- it "should have appropriate defaults" do
30
- mock_factory = mock("BinaryProtocolFactory")
31
- mock_proc = mock("Processor")
32
- BinaryProtocolFactory.should_receive(:new).and_return(mock_factory)
33
- Mongrel::HttpServer.should_receive(:new).with("0.0.0.0", 80).and_return do
34
- mock("Mongrel::HttpServer").tee do |mock|
35
- handler = mock("Handler")
36
- Handler.should_receive(:new).with(mock_proc, mock_factory).and_return(handler)
37
- mock.should_receive(:register).with("/", handler)
38
- end
39
- end
40
- MongrelHTTPServer.new(mock_proc)
41
- end
42
-
43
- it "should understand :ip, :port, :path, and :protocol_factory" do
44
- mock_proc = mock("Processor")
45
- mock_factory = mock("ProtocolFactory")
46
- Mongrel::HttpServer.should_receive(:new).with("1.2.3.4", 1234).and_return do
47
- mock("Mongrel::HttpServer").tee do |mock|
48
- handler = mock("Handler")
49
- Handler.should_receive(:new).with(mock_proc, mock_factory).and_return(handler)
50
- mock.should_receive(:register).with("/foo", handler)
51
- end
52
- end
53
- MongrelHTTPServer.new(mock_proc, :ip => "1.2.3.4", :port => 1234, :path => "foo",
54
- :protocol_factory => mock_factory)
55
- end
56
-
57
- it "should serve using Mongrel::HttpServer" do
58
- BinaryProtocolFactory.stub!(:new)
59
- Mongrel::HttpServer.should_receive(:new).and_return do
60
- mock("Mongrel::HttpServer").tee do |mock|
61
- Handler.stub!(:new)
62
- mock.stub!(:register)
63
- mock.should_receive(:run).and_return do
64
- mock("Mongrel::HttpServer.run").tee do |runner|
65
- runner.should_receive(:join)
66
- end
67
- end
68
- end
69
- end
70
- MongrelHTTPServer.new(nil).serve
71
- end
72
- end
73
-
74
- describe MongrelHTTPServer::Handler do
75
- before(:each) do
76
- @processor = mock("Processor")
77
- @factory = mock("ProtocolFactory")
78
- @handler = Handler.new(@processor, @factory)
79
- end
80
-
81
- it "should return 404 for non-POST requests" do
82
- request = mock("request", :params => {"REQUEST_METHOD" => "GET"})
83
- response = mock("response")
84
- response.should_receive(:start).with(404)
85
- response.should_not_receive(:start).with(200)
86
- @handler.process(request, response)
87
- end
88
-
89
- it "should serve using application/x-thrift" do
90
- request = mock("request", :params => {"REQUEST_METHOD" => "POST"}, :body => nil)
91
- response = mock("response")
92
- head = mock("head")
93
- head.should_receive(:[]=).with("Content-Type", "application/x-thrift")
94
- IOStreamTransport.stub!(:new)
95
- @factory.stub!(:get_protocol)
96
- @processor.stub!(:process)
97
- response.should_receive(:start).with(200).and_yield(head, nil)
98
- @handler.process(request, response)
99
- end
100
-
101
- it "should use the IOStreamTransport" do
102
- body = mock("body")
103
- request = mock("request", :params => {"REQUEST_METHOD" => "POST"}, :body => body)
104
- response = mock("response")
105
- head = mock("head")
106
- head.stub!(:[]=)
107
- out = mock("out")
108
- protocol = mock("protocol")
109
- transport = mock("transport")
110
- IOStreamTransport.should_receive(:new).with(body, out).and_return(transport)
111
- @factory.should_receive(:get_protocol).with(transport).and_return(protocol)
112
- @processor.should_receive(:process).with(protocol, protocol)
113
- response.should_receive(:start).with(200).and_yield(head, out)
114
- @handler.process(request, response)
115
- end
116
- end
117
- end