forked from kookster/activemessaging
-
Notifications
You must be signed in to change notification settings - Fork 5
/
jms_test.rb
61 lines (49 loc) · 1.76 KB
/
jms_test.rb
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
require File.dirname(__FILE__) + '/test_helper'
if defined?(JRUBY_VERSION)
class JmsTest < Test::Unit::TestCase
def setup
@test_txt = 'Yo Homie!'
@isolation_const = rand(99999999)
@connection = ActiveMessaging::Adapters::Jms::Connection.new(:url => 'tcp://localhost:61616',
:login => '',
:passcode => '',
:connection_factory => 'org.apache.activemq.ActiveMQConnectionFactory')
end
def test_send
@connection.send "/queue/TestQueue#{@isolation_const}", @test_txt, {}
end
def test_receive_with_one
@connection.send "/queue/TestQueue#{@isolation_const}", @test_txt
@connection.subscribe "/queue/TestQueue#{@isolation_const}"
message = @connection.receive
assert_equal @test_txt, message.body
end
def test_receive_multi
10.times do |i|
@connection.send "/queue/MultiQueue#{@isolation_const}", @test_txt
end
counter=0
@connection.subscribe "/queue/MultiQueue#{@isolation_const}"
while message = @connection.receive
assert_equal @test_txt, message.body
counter += 1
end
assert_equal 10, counter
end
def test_one_off_receive
@connection.send "/queue/OneOff#{@isolation_const}", "one off message"
message = @connection.receive "/queue/OneOff#{@isolation_const}"
assert_equal "one off message", message.body
assert_equal "MESSAGE", message.command
assert_equal "/queue/OneOff#{@isolation_const}", message.headers['destination']
end
def test_unsubscribe
@connection.subscribe "/queue/TestSubQueue#{@isolation_const}"
@connection.unsubscribe "/queue/TestSubQueue#{@isolation_const}"
assert_nil @connection.consumers["TestSubQueue#{@isolation_const}"]
end
def teardown
@connection.close unless @connection.nil?
end
end
end