amq-protocol 2.4.0 → 2.5.1
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/ChangeLog.md +12 -5
- data/lib/amq/protocol/client.rb +30 -37
- data/lib/amq/protocol/frame.rb +2 -0
- data/lib/amq/protocol/version.rb +1 -1
- metadata +3 -52
- data/.github/ISSUE_TEMPLATE.md +0 -18
- data/.github/workflows/ci.yml +0 -31
- data/.gitignore +0 -18
- data/.gitmodules +0 -3
- data/.rspec +0 -1
- data/.travis.yml +0 -17
- data/Gemfile +0 -27
- data/Rakefile +0 -55
- data/amq-protocol.gemspec +0 -27
- data/benchmarks/frame_encoding.rb +0 -75
- data/benchmarks/int_allocator.rb +0 -34
- data/benchmarks/method_encoding.rb +0 -198
- data/benchmarks/pack_unpack.rb +0 -158
- data/benchmarks/pure/body_framing_with_256k_payload.rb +0 -28
- data/benchmarks/pure/body_framing_with_2k_payload.rb +0 -28
- data/benchmarks/run_all.rb +0 -64
- data/benchmarks/table_encoding.rb +0 -110
- data/codegen/__init__.py +0 -0
- data/codegen/amqp_0.9.1_changes.json +0 -1
- data/codegen/codegen.py +0 -151
- data/codegen/codegen_helpers.py +0 -162
- data/codegen/protocol.rb.pytemplate +0 -320
- data/generate.rb +0 -24
- data/profiling/README.md +0 -9
- data/profiling/stackprof/body_framing_with_2k_payload.rb +0 -33
- data/spec/amq/bit_set_spec.rb +0 -249
- data/spec/amq/endianness_spec.rb +0 -23
- data/spec/amq/int_allocator_spec.rb +0 -136
- data/spec/amq/pack_spec.rb +0 -58
- data/spec/amq/protocol/basic_spec.rb +0 -325
- data/spec/amq/protocol/blank_body_encoding_spec.rb +0 -9
- data/spec/amq/protocol/channel_spec.rb +0 -127
- data/spec/amq/protocol/confirm_spec.rb +0 -41
- data/spec/amq/protocol/connection_spec.rb +0 -146
- data/spec/amq/protocol/constants_spec.rb +0 -10
- data/spec/amq/protocol/exceptions_spec.rb +0 -70
- data/spec/amq/protocol/exchange_spec.rb +0 -106
- data/spec/amq/protocol/float_32bit_spec.rb +0 -27
- data/spec/amq/protocol/frame_spec.rb +0 -156
- data/spec/amq/protocol/method_spec.rb +0 -43
- data/spec/amq/protocol/queue_spec.rb +0 -126
- data/spec/amq/protocol/table_spec.rb +0 -291
- data/spec/amq/protocol/tx_spec.rb +0 -55
- data/spec/amq/protocol/value_decoder_spec.rb +0 -183
- data/spec/amq/protocol/value_encoder_spec.rb +0 -161
- data/spec/amq/protocol_spec.rb +0 -812
- data/spec/amq/settings_spec.rb +0 -58
- data/spec/amq/uri_parsing_spec.rb +0 -287
- data/spec/spec_helper.rb +0 -29
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# encoding: binary
|
|
2
|
-
|
|
3
|
-
RSpec.describe AMQ::Protocol::Error do
|
|
4
|
-
describe ".[]" do
|
|
5
|
-
it "looks up exception class by error code" do
|
|
6
|
-
# This only works if subclasses define VALUE constant
|
|
7
|
-
# Default case: no subclass with VALUE defined returns nil
|
|
8
|
-
expect { described_class[999999] }.to raise_error(/No such exception class/)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe ".subclasses_with_values" do
|
|
13
|
-
it "returns subclasses that define VALUE constant" do
|
|
14
|
-
result = described_class.subclasses_with_values
|
|
15
|
-
expect(result).to be_an(Array)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe "#initialize" do
|
|
20
|
-
it "uses default message when none provided" do
|
|
21
|
-
error = described_class.new
|
|
22
|
-
expect(error.message).to eq("AMQP error")
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "uses custom message when provided" do
|
|
26
|
-
error = described_class.new("Custom error")
|
|
27
|
-
expect(error.message).to eq("Custom error")
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
RSpec.describe AMQ::Protocol::FrameTypeError do
|
|
33
|
-
it "formats message with valid types" do
|
|
34
|
-
error = described_class.new([:method, :headers])
|
|
35
|
-
expect(error.message).to include("[:method, :headers]")
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
RSpec.describe AMQ::Protocol::EmptyResponseError do
|
|
40
|
-
it "has a default message" do
|
|
41
|
-
error = described_class.new
|
|
42
|
-
expect(error.message).to eq("Empty response received from the server.")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "accepts custom message" do
|
|
46
|
-
error = described_class.new("Custom empty response")
|
|
47
|
-
expect(error.message).to eq("Custom empty response")
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
RSpec.describe AMQ::Protocol::BadResponseError do
|
|
52
|
-
it "formats message with argument, expected, and actual values" do
|
|
53
|
-
error = described_class.new("channel", 1, 2)
|
|
54
|
-
expect(error.message).to include("channel")
|
|
55
|
-
expect(error.message).to include("1")
|
|
56
|
-
expect(error.message).to include("2")
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
RSpec.describe AMQ::Protocol::SoftError do
|
|
61
|
-
it "is a subclass of Protocol::Error" do
|
|
62
|
-
expect(described_class.superclass).to eq(AMQ::Protocol::Error)
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
RSpec.describe AMQ::Protocol::HardError do
|
|
67
|
-
it "is a subclass of Protocol::Error" do
|
|
68
|
-
expect(described_class.superclass).to eq(AMQ::Protocol::Error)
|
|
69
|
-
end
|
|
70
|
-
end
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# encoding: binary
|
|
2
|
-
|
|
3
|
-
module AMQ
|
|
4
|
-
module Protocol
|
|
5
|
-
class Exchange
|
|
6
|
-
RSpec.describe Declare do
|
|
7
|
-
describe '.encode' do
|
|
8
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
9
|
-
channel = 1
|
|
10
|
-
exchange = 'amqclient.adapters.em.exchange1'
|
|
11
|
-
type = 'fanout'
|
|
12
|
-
passive = false
|
|
13
|
-
durable = false
|
|
14
|
-
auto_delete = false
|
|
15
|
-
internal = false
|
|
16
|
-
nowait = false
|
|
17
|
-
arguments = nil
|
|
18
|
-
method_frame = Declare.encode(channel, exchange, type, passive, durable, auto_delete, internal, nowait, arguments)
|
|
19
|
-
expect(method_frame.payload).to eq("\x00(\x00\n\x00\x00\x1Famqclient.adapters.em.exchange1\x06fanout\x00\x00\x00\x00\x00")
|
|
20
|
-
expect(method_frame.channel).to eq(1)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
RSpec.describe Declare, "encoded with a symbol name" do
|
|
26
|
-
describe '.encode' do
|
|
27
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
28
|
-
channel = 1
|
|
29
|
-
exchange = :exchange2
|
|
30
|
-
type = 'fanout'
|
|
31
|
-
passive = false
|
|
32
|
-
durable = false
|
|
33
|
-
auto_delete = false
|
|
34
|
-
internal = false
|
|
35
|
-
nowait = false
|
|
36
|
-
arguments = nil
|
|
37
|
-
method_frame = Declare.encode(channel, exchange, type, passive, durable, auto_delete, internal, nowait, arguments)
|
|
38
|
-
expect(method_frame.payload).to eq("\x00(\x00\n\x00\x00\texchange2\x06fanout\x00\x00\x00\x00\x00")
|
|
39
|
-
expect(method_frame.channel).to eq(1)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
RSpec.describe Delete do
|
|
45
|
-
describe '.encode' do
|
|
46
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
47
|
-
channel = 1
|
|
48
|
-
exchange = 'amqclient.adapters.em.exchange'
|
|
49
|
-
if_unused = false
|
|
50
|
-
nowait = false
|
|
51
|
-
method_frame = Delete.encode(channel, exchange, if_unused, nowait)
|
|
52
|
-
expect(method_frame.payload).to eq("\x00(\x00\x14\x00\x00\x1Eamqclient.adapters.em.exchange\x00")
|
|
53
|
-
expect(method_frame.channel).to eq(1)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# RSpec.describe DeleteOk do
|
|
59
|
-
# describe '.decode' do
|
|
60
|
-
# end
|
|
61
|
-
# end
|
|
62
|
-
|
|
63
|
-
RSpec.describe Bind do
|
|
64
|
-
describe '.encode' do
|
|
65
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
66
|
-
channel = 1
|
|
67
|
-
destination = 'foo'
|
|
68
|
-
source = 'bar'
|
|
69
|
-
routing_key = 'xyz'
|
|
70
|
-
nowait = false
|
|
71
|
-
arguments = nil
|
|
72
|
-
method_frame = Bind.encode(channel, destination, source, routing_key, nowait, arguments)
|
|
73
|
-
expect(method_frame.payload).to eq("\x00(\x00\x1E\x00\x00\x03foo\x03bar\x03xyz\x00\x00\x00\x00\x00")
|
|
74
|
-
expect(method_frame.channel).to eq(1)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# RSpec.describe BindOk do
|
|
80
|
-
# describe '.decode' do
|
|
81
|
-
# end
|
|
82
|
-
# end
|
|
83
|
-
|
|
84
|
-
RSpec.describe Unbind do
|
|
85
|
-
describe '.encode' do
|
|
86
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
87
|
-
channel = 1
|
|
88
|
-
destination = 'foo'
|
|
89
|
-
source = 'bar'
|
|
90
|
-
routing_key = 'xyz'
|
|
91
|
-
nowait = false
|
|
92
|
-
arguments = nil
|
|
93
|
-
method_frame = Unbind.encode(channel, destination, source, routing_key, nowait, arguments)
|
|
94
|
-
expect(method_frame.payload).to eq("\x00(\x00(\x00\x00\x03foo\x03bar\x03xyz\x00\x00\x00\x00\x00")
|
|
95
|
-
expect(method_frame.channel).to eq(1)
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
# RSpec.describe UnbindOk do
|
|
101
|
-
# describe '.decode' do
|
|
102
|
-
# end
|
|
103
|
-
# end
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# encoding: binary
|
|
2
|
-
|
|
3
|
-
RSpec.describe AMQ::Protocol::Float32Bit do
|
|
4
|
-
describe "#initialize" do
|
|
5
|
-
it "stores the value" do
|
|
6
|
-
f = described_class.new(3.14)
|
|
7
|
-
expect(f.value).to eq(3.14)
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
describe "#value" do
|
|
12
|
-
it "returns the stored value" do
|
|
13
|
-
f = described_class.new(2.718)
|
|
14
|
-
expect(f.value).to eq(2.718)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "works with zero" do
|
|
18
|
-
f = described_class.new(0.0)
|
|
19
|
-
expect(f.value).to eq(0.0)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "works with negative values" do
|
|
23
|
-
f = described_class.new(-1.5)
|
|
24
|
-
expect(f.value).to eq(-1.5)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
module AMQ
|
|
2
|
-
module Protocol
|
|
3
|
-
RSpec.describe Frame do
|
|
4
|
-
describe ".encode" do
|
|
5
|
-
it "should raise FrameTypeError if type isn't one of: [:method, :header, :body, :heartbeat]" do
|
|
6
|
-
expect { Frame.encode(nil, "", 0) }.to raise_error(FrameTypeError)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "should raise FrameTypeError if type isn't valid (when type is a symbol)" do
|
|
10
|
-
expect { Frame.encode(:xyz, "test", 12) }.to raise_error(FrameTypeError)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "should raise FrameTypeError if type isn't valid (when type is a number)" do
|
|
14
|
-
expect { Frame.encode(16, "test", 12) }.to raise_error(FrameTypeError)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should raise RuntimeError if channel isn't 0 or an integer in range 1..65535" do
|
|
18
|
-
expect { Frame.encode(:method, "", -1) }.to raise_error(RuntimeError, /^Channel has to be 0 or an integer in range 1\.\.65535/)
|
|
19
|
-
expect { Frame.encode(:method, "", 65536) }.to raise_error(RuntimeError, /^Channel has to be 0 or an integer in range 1\.\.65535/)
|
|
20
|
-
expect { Frame.encode(:method, "", 65535) }.not_to raise_error
|
|
21
|
-
expect { Frame.encode(:method, "", 0) }.not_to raise_error
|
|
22
|
-
expect { Frame.encode(:method, "", 1) }.not_to raise_error
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "should raise RuntimeError if payload is nil" do
|
|
26
|
-
expect { Frame.encode(:method, nil, 0) }.to raise_error(RuntimeError, "Payload can't be nil")
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should encode type" do
|
|
30
|
-
expect(Frame.encode(:body, "", 0).unpack("c").first).to eql(3)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should encode channel" do
|
|
34
|
-
expect(Frame.encode(:body, "", 12).unpack("cn").last).to eql(12)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "should encode size" do
|
|
38
|
-
expect(Frame.encode(:body, "test", 12).unpack("cnN").last).to eql(4)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should include payload" do
|
|
42
|
-
expect(Frame.encode(:body, "test", 12)[7..-2]).to eql("test")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "should include final octet" do
|
|
46
|
-
expect(Frame.encode(:body, "test", 12).each_byte.to_a.last).to eq("CE".hex)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should encode unicode strings" do
|
|
50
|
-
expect { Frame.encode(:body, "à bientôt!", 12) }.to_not raise_error
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe ".new" do
|
|
55
|
-
it "should raise FrameTypeError if the type is not one of the accepted" do
|
|
56
|
-
expect { Frame.new(10) }.to raise_error(FrameTypeError)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe '#decode_header' do
|
|
61
|
-
it 'raises FrameTypeError if the decoded type is not one of the accepted' do
|
|
62
|
-
expect { Frame.decode_header("\n\x00\x01\x00\x00\x00\x05") }.to raise_error(FrameTypeError)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it 'raises EmptyResponseError if the header is nil' do
|
|
66
|
-
expect { Frame.decode_header(nil) }.to raise_error(EmptyResponseError)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
describe HeaderFrame do
|
|
71
|
-
subject { HeaderFrame.new("\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\n\x98\x00\x18application/octet-stream\x02\x00", nil) }
|
|
72
|
-
|
|
73
|
-
it "should decode body_size from payload" do
|
|
74
|
-
expect(subject.body_size).to eq(10)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "should decode klass_id from payload" do
|
|
78
|
-
expect(subject.klass_id).to eq(60)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "should decode weight from payload" do
|
|
82
|
-
expect(subject.weight).to eq(0)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it "should decode properties from payload" do
|
|
86
|
-
expect(subject.properties[:delivery_mode]).to eq(2)
|
|
87
|
-
expect(subject.properties[:priority]).to eq(0)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "is not final" do
|
|
91
|
-
expect(subject.final?).to eq(false)
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
describe BodyFrame do
|
|
96
|
-
subject { BodyFrame.new("test payload", 1) }
|
|
97
|
-
|
|
98
|
-
it "returns payload as decode_payload" do
|
|
99
|
-
expect(subject.decode_payload).to eq("test payload")
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it "is not final" do
|
|
103
|
-
expect(subject.final?).to eq(false)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it "has correct size" do
|
|
107
|
-
expect(subject.size).to eq(12)
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
describe HeartbeatFrame do
|
|
112
|
-
it "encodes with empty payload on channel 0" do
|
|
113
|
-
encoded = HeartbeatFrame.encode
|
|
114
|
-
expect(encoded.bytes.last).to eq(0xCE)
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "is final" do
|
|
118
|
-
frame = HeartbeatFrame.new("", 0)
|
|
119
|
-
expect(frame.final?).to eq(true)
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
describe MethodFrame do
|
|
124
|
-
it "is not final when method has content" do
|
|
125
|
-
# Basic.Publish has content
|
|
126
|
-
payload = "\x00\x3C\x00\x28\x00\x00\x00\x00\x00"
|
|
127
|
-
frame = MethodFrame.new(payload, 1)
|
|
128
|
-
# This will depend on the method class
|
|
129
|
-
expect(frame).to respond_to(:final?)
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
describe FrameSubclass do
|
|
134
|
-
subject { BodyFrame.new("test", 1) }
|
|
135
|
-
|
|
136
|
-
it "has channel accessor" do
|
|
137
|
-
expect(subject.channel).to eq(1)
|
|
138
|
-
subject.channel = 2
|
|
139
|
-
expect(subject.channel).to eq(2)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "encodes to array" do
|
|
143
|
-
result = subject.encode_to_array
|
|
144
|
-
expect(result).to be_an(Array)
|
|
145
|
-
expect(result.size).to eq(3)
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
it "encodes to string" do
|
|
149
|
-
result = subject.encode
|
|
150
|
-
expect(result).to be_a(String)
|
|
151
|
-
expect(result.bytes.last).to eq(0xCE)
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
module AMQ
|
|
2
|
-
module Protocol
|
|
3
|
-
RSpec.describe Method do
|
|
4
|
-
describe '.split_headers' do
|
|
5
|
-
it 'splits user defined headers into properties and headers' do
|
|
6
|
-
input = {:delivery_mode => 2, :content_type => 'application/octet-stream', :foo => 'bar'}
|
|
7
|
-
properties, headers = Method.split_headers(input)
|
|
8
|
-
expect(properties).to eq({:delivery_mode => 2, :content_type => 'application/octet-stream'})
|
|
9
|
-
expect(headers).to eq({:foo => 'bar'})
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe '.encode_body' do
|
|
14
|
-
context 'when the body fits in a single frame' do
|
|
15
|
-
it 'encodes a body into a BodyFrame' do
|
|
16
|
-
body_frames = Method.encode_body('Hello world', 1, 131072)
|
|
17
|
-
expect(body_frames.first.payload).to eq('Hello world')
|
|
18
|
-
expect(body_frames.first.channel).to eq(1)
|
|
19
|
-
expect(body_frames.size).to eq(1)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context 'when the body is too big to fit in a single frame' do
|
|
24
|
-
it 'encodes a body into a list of BodyFrames that each fit within the frame size' do
|
|
25
|
-
lipsum = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
|
|
26
|
-
frame_size = 100
|
|
27
|
-
expected_payload_size = 92
|
|
28
|
-
body_frames = Method.encode_body(lipsum, 1, frame_size)
|
|
29
|
-
expect(body_frames.map(&:payload)).to eq(lipsum.split('').each_slice(expected_payload_size).map(&:join))
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context 'when the body fits perfectly in a single frame' do
|
|
34
|
-
it 'encodes a body into a single BodyFrame' do
|
|
35
|
-
body_frames = Method.encode_body('*' * 131064, 1, 131072)
|
|
36
|
-
expect(body_frames.first.payload).to eq('*' * 131064)
|
|
37
|
-
expect(body_frames.size).to eq(1)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
# encoding: binary
|
|
2
|
-
|
|
3
|
-
module AMQ
|
|
4
|
-
module Protocol
|
|
5
|
-
class Queue
|
|
6
|
-
RSpec.describe Declare do
|
|
7
|
-
describe '.encode' do
|
|
8
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
9
|
-
channel = 1
|
|
10
|
-
queue = 'hello.world'
|
|
11
|
-
passive = false
|
|
12
|
-
durable = true
|
|
13
|
-
exclusive = true
|
|
14
|
-
auto_delete = true
|
|
15
|
-
nowait = false
|
|
16
|
-
arguments = nil
|
|
17
|
-
method_frame = Declare.encode(channel, queue, passive, durable, exclusive, auto_delete, nowait, arguments)
|
|
18
|
-
expect(method_frame.payload).to eq("\x002\x00\n\x00\x00\vhello.world\x0E\x00\x00\x00\x00")
|
|
19
|
-
expect(method_frame.channel).to eq(1)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
RSpec.describe DeclareOk do
|
|
25
|
-
describe '.decode' do
|
|
26
|
-
subject do
|
|
27
|
-
DeclareOk.decode(" amq.gen-KduGSqQrpeUo1otnU0TWSA==\x00\x00\x00\x00\x00\x00\x00\x00")
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
its(:queue) { should eq('amq.gen-KduGSqQrpeUo1otnU0TWSA==') }
|
|
31
|
-
its(:message_count) { should eq(0) }
|
|
32
|
-
its(:consumer_count) { should eq(0) }
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
RSpec.describe Bind do
|
|
37
|
-
describe '.encode' do
|
|
38
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
39
|
-
channel = 1
|
|
40
|
-
queue = 'hello.world'
|
|
41
|
-
exchange = 'foo.bar'
|
|
42
|
-
routing_key = 'xyz'
|
|
43
|
-
nowait = false
|
|
44
|
-
arguments = nil
|
|
45
|
-
method_frame = Bind.encode(channel, queue, exchange, routing_key, nowait, arguments)
|
|
46
|
-
expect(method_frame.payload).to eq("\x002\x00\x14\x00\x00\vhello.world\afoo.bar\x03xyz\x00\x00\x00\x00\x00")
|
|
47
|
-
expect(method_frame.channel).to eq(1)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# RSpec.describe BindOk do
|
|
53
|
-
# describe '.decode' do
|
|
54
|
-
# end
|
|
55
|
-
# end
|
|
56
|
-
|
|
57
|
-
RSpec.describe Purge do
|
|
58
|
-
describe '.encode' do
|
|
59
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
60
|
-
channel = 1
|
|
61
|
-
queue = 'hello.world'
|
|
62
|
-
nowait = false
|
|
63
|
-
method_frame = Purge.encode(channel, queue, nowait)
|
|
64
|
-
expect(method_frame.payload).to eq("\x002\x00\x1E\x00\x00\vhello.world\x00")
|
|
65
|
-
expect(method_frame.channel).to eq(1)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
RSpec.describe PurgeOk do
|
|
71
|
-
describe '.decode' do
|
|
72
|
-
subject do
|
|
73
|
-
PurgeOk.decode("\x00\x00\x00\x02")
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
its(:message_count) { should eq(2) }
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
RSpec.describe Delete do
|
|
81
|
-
describe '.encode' do
|
|
82
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
83
|
-
channel = 1
|
|
84
|
-
queue = 'hello.world'
|
|
85
|
-
if_unused = false
|
|
86
|
-
if_empty = false
|
|
87
|
-
nowait = false
|
|
88
|
-
method_frame = Delete.encode(channel, queue, if_unused, if_empty, nowait)
|
|
89
|
-
expect(method_frame.payload).to eq("\x002\x00(\x00\x00\vhello.world\x00")
|
|
90
|
-
expect(method_frame.channel).to eq(1)
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
RSpec.describe DeleteOk do
|
|
96
|
-
describe '.decode' do
|
|
97
|
-
subject do
|
|
98
|
-
DeleteOk.decode("\x00\x00\x00\x02")
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
its(:message_count) { should eq(2) }
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
RSpec.describe Unbind do
|
|
106
|
-
describe '.encode' do
|
|
107
|
-
it 'encodes the parameters into a MethodFrame' do
|
|
108
|
-
channel = 1
|
|
109
|
-
queue = 'hello.world'
|
|
110
|
-
exchange = 'foo.bar'
|
|
111
|
-
routing_key = 'xyz'
|
|
112
|
-
arguments = nil
|
|
113
|
-
method_frame = Unbind.encode(channel, queue, exchange, routing_key, arguments)
|
|
114
|
-
expect(method_frame.payload).to eq("\x002\x002\x00\x00\vhello.world\afoo.bar\x03xyz\x00\x00\x00\x00")
|
|
115
|
-
expect(method_frame.channel).to eq(1)
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# RSpec.describe UnbindOk do
|
|
121
|
-
# describe '.decode' do
|
|
122
|
-
# end
|
|
123
|
-
# end
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|