File: exchange_spec.rb

package info (click to toggle)
ruby-amq-protocol 0.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 392 kB
  • sloc: ruby: 4,212; python: 247; makefile: 2
file content (95 lines) | stat: -rw-r--r-- 2,900 bytes parent folder | download
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
# encoding: binary

require File.expand_path('../../../spec_helper', __FILE__)


module AMQ
  module Protocol
    class Exchange
      describe Declare do
        describe '.encode' do
          it 'encodes the parameters into a MethodFrame' do
            channel = 1
            exchange = 'amqclient.adapters.em.exchange1'
            type = 'fanout'
            passive = false
            durable = false
            auto_delete = false
            internal = false
            nowait = false
            arguments = nil
            method_frame = Declare.encode(channel, exchange, type, passive, durable, auto_delete, internal, nowait, arguments)
            method_frame.payload.should == "\x00(\x00\n\x00\x00\x1Famqclient.adapters.em.exchange1\x06fanout\x00\x00\x00\x00\x00"
            method_frame.channel.should == 1
          end
        end
      end

      # describe DeclareOk do
      #   describe '.decode' do
      #   end
      # end

      describe Delete do
        describe '.encode' do
          it 'encodes the parameters into a MethodFrame' do
            channel = 1
            exchange = 'amqclient.adapters.em.exchange'
            if_unused = false
            nowait = false
            method_frame = Delete.encode(channel, exchange, if_unused, nowait)
            method_frame.payload.should == "\x00(\x00\x14\x00\x00\x1Eamqclient.adapters.em.exchange\x00"
            method_frame.channel.should == 1
          end
        end
      end

      # describe DeleteOk do
      #   describe '.decode' do
      #   end
      # end

      describe Bind do
        describe '.encode' do
          it 'encodes the parameters into a MethodFrame' do
            channel = 1
            destination = 'foo'
            source = 'bar'
            routing_key = 'xyz'
            nowait = false
            arguments = nil
            method_frame = Bind.encode(channel, destination, source, routing_key, nowait, arguments)
            method_frame.payload.should == "\x00(\x00\x1E\x00\x00\x03foo\x03bar\x03xyz\x00\x00\x00\x00\x00"
            method_frame.channel.should == 1
          end
        end
      end

      # describe BindOk do
      #   describe '.decode' do
      #   end
      # end

      describe Unbind do
        describe '.encode' do
          it 'encodes the parameters into a MethodFrame' do
            channel = 1
            destination = 'foo'
            source = 'bar'
            routing_key = 'xyz'
            nowait = false
            arguments = nil
            method_frame = Unbind.encode(channel, destination, source, routing_key, nowait, arguments)
            method_frame.payload.should == "\x00(\x00(\x00\x00\x03foo\x03bar\x03xyz\x00\x00\x00\x00\x00"
            method_frame.channel.should == 1
          end
        end
      end

      # describe UnbindOk do
      #   describe '.decode' do
      #   end
      # end
    end
  end
end