1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
# encoding: binary
require File.expand_path('../../../spec_helper', __FILE__)
module AMQ
module Protocol
class Queue
describe Declare do
describe '.encode' do
it 'encodes the parameters into a MethodFrame' do
channel = 1
queue = 'hello.world'
passive = false
durable = true
exclusive = true
auto_delete = true
nowait = false
arguments = nil
method_frame = Declare.encode(channel, queue, passive, durable, exclusive, auto_delete, nowait, arguments)
method_frame.payload.should == "\x002\x00\n\x00\x00\vhello.world\x0E\x00\x00\x00\x00"
method_frame.channel.should == 1
end
end
end
describe DeclareOk do
describe '.decode' do
subject do
DeclareOk.decode(" amq.gen-KduGSqQrpeUo1otnU0TWSA==\x00\x00\x00\x00\x00\x00\x00\x00")
end
its(:queue) { should == 'amq.gen-KduGSqQrpeUo1otnU0TWSA==' }
its(:message_count) { should == 0 }
its(:consumer_count) { should == 0 }
end
end
describe Bind do
describe '.encode' do
it 'encodes the parameters into a MethodFrame' do
channel = 1
queue = 'hello.world'
exchange = 'foo.bar'
routing_key = 'xyz'
nowait = false
arguments = nil
method_frame = Bind.encode(channel, queue, exchange, routing_key, nowait, arguments)
method_frame.payload.should == "\x002\x00\x14\x00\x00\vhello.world\afoo.bar\x03xyz\x00\x00\x00\x00\x00"
method_frame.channel.should == 1
end
end
end
# describe BindOk do
# describe '.decode' do
# end
# end
describe Purge do
describe '.encode' do
it 'encodes the parameters into a MethodFrame' do
channel = 1
queue = 'hello.world'
nowait = false
method_frame = Purge.encode(channel, queue, nowait)
method_frame.payload.should == "\x002\x00\x1E\x00\x00\vhello.world\x00"
method_frame.channel.should == 1
end
end
end
describe PurgeOk do
describe '.decode' do
subject do
PurgeOk.decode("\x00\x00\x00\x02")
end
its(:message_count) { should == 2 }
end
end
describe Delete do
describe '.encode' do
it 'encodes the parameters into a MethodFrame' do
channel = 1
queue = 'hello.world'
if_unused = false
if_empty = false
nowait = false
method_frame = Delete.encode(channel, queue, if_unused, if_empty, nowait)
method_frame.payload.should == "\x002\x00(\x00\x00\vhello.world\x00"
method_frame.channel.should == 1
end
end
end
describe DeleteOk do
describe '.decode' do
subject do
DeleteOk.decode("\x00\x00\x00\x02")
end
its(:message_count) { should == 2 }
end
end
describe Unbind do
describe '.encode' do
it 'encodes the parameters into a MethodFrame' do
channel = 1
queue = 'hello.world'
exchange = 'foo.bar'
routing_key = 'xyz'
arguments = nil
method_frame = Unbind.encode(channel, queue, exchange, routing_key, arguments)
method_frame.payload.should == "\x002\x002\x00\x00\vhello.world\afoo.bar\x03xyz\x00\x00\x00\x00"
method_frame.channel.should == 1
end
end
end
# describe UnbindOk do
# describe '.decode' do
# end
# end
end
end
end
|