mosquitto 0.2 → 0.3
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/.gitignore +2 -1
- data/.travis.yml +11 -8
- data/Gemfile +1 -4
- data/Gemfile.lock +3 -8
- data/README.md +22 -22
- data/Rakefile +16 -12
- data/ext/mosquitto/client.c +108 -40
- data/ext/mosquitto/client.h +12 -2
- data/ext/mosquitto/extconf.rb +29 -10
- data/ext/mosquitto/mosquitto_prelude.h +2 -2
- data/lib/mosquitto/client.rb +22 -0
- data/lib/mosquitto/logging.rb +15 -2
- data/lib/mosquitto/version.rb +1 -1
- data/test/helper.rb +6 -15
- data/test/mosquitto.conf.erb +734 -0
- data/test/test_callbacks.rb +11 -7
- data/test/test_client.rb +12 -10
- data/test/test_custom_logger.rb +7 -2
- data/test/test_integration.rb +45 -19
- data/test/test_loops.rb +22 -10
- data/test/test_mosquitto.rb +1 -1
- data/test/test_pub_sub.rb +18 -4
- data/test/test_threads.rb +10 -6
- data/test/test_tls.rb +3 -2
- metadata +14 -13
data/test/test_callbacks.rb
CHANGED
@@ -14,7 +14,7 @@ class TestCallbacks < MosquittoTestCase
|
|
14
14
|
client.on_disconnect do |rc|
|
15
15
|
disconnected = true
|
16
16
|
end
|
17
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
17
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
18
18
|
client.wait_readable
|
19
19
|
assert client.disconnect
|
20
20
|
sleep 3
|
@@ -30,11 +30,13 @@ class TestCallbacks < MosquittoTestCase
|
|
30
30
|
client.on_log do |level, msg|
|
31
31
|
logs << msg
|
32
32
|
end
|
33
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
34
|
-
assert client.disconnect
|
33
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
35
34
|
client.wait_readable
|
36
|
-
assert_equal
|
35
|
+
assert_equal 1, logs.size
|
37
36
|
assert_match(/CONNECT/, logs[0])
|
37
|
+
assert client.disconnect
|
38
|
+
sleep 0.5
|
39
|
+
assert_equal 2, logs.size
|
38
40
|
assert_match(/DISCONNECT/, logs[1])
|
39
41
|
end
|
40
42
|
|
@@ -56,7 +58,7 @@ class TestCallbacks < MosquittoTestCase
|
|
56
58
|
client.on_unsubscribe do |mid|
|
57
59
|
unsubscribed = true
|
58
60
|
end
|
59
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
61
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
60
62
|
client.wait_readable
|
61
63
|
assert subscribed
|
62
64
|
assert unsubscribed
|
@@ -73,8 +75,9 @@ class TestCallbacks < MosquittoTestCase
|
|
73
75
|
publisher.on_connect do |rc|
|
74
76
|
publisher.publish(nil, "message_callback", "test", Mosquitto::AT_MOST_ONCE, true)
|
75
77
|
end
|
76
|
-
publisher.connect(TEST_HOST, TEST_PORT,
|
78
|
+
publisher.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
77
79
|
publisher.wait_readable
|
80
|
+
|
78
81
|
publisher.loop_stop(true)
|
79
82
|
|
80
83
|
subscriber = Mosquitto::Client.new
|
@@ -82,11 +85,12 @@ class TestCallbacks < MosquittoTestCase
|
|
82
85
|
subscriber.on_connect do |rc|
|
83
86
|
subscriber.subscribe(nil, "message_callback", Mosquitto::AT_MOST_ONCE)
|
84
87
|
end
|
85
|
-
subscriber.connect(TEST_HOST, TEST_PORT, 10)
|
86
88
|
subscriber.on_message do |msg|
|
87
89
|
message = msg
|
88
90
|
end
|
91
|
+
subscriber.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
89
92
|
subscriber.wait_readable
|
93
|
+
|
90
94
|
subscriber.loop_stop(true)
|
91
95
|
assert_equal "test", message.to_s
|
92
96
|
end
|
data/test/test_client.rb
CHANGED
@@ -50,9 +50,9 @@ class TestClient < MosquittoTestCase
|
|
50
50
|
client = Mosquitto::Client.new
|
51
51
|
assert client.loop_start
|
52
52
|
assert_raises TypeError do
|
53
|
-
client.connect(:invalid, TEST_PORT,
|
53
|
+
client.connect(:invalid, TEST_PORT, TIMEOUT)
|
54
54
|
end
|
55
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
55
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
56
56
|
ensure
|
57
57
|
client.loop_stop(true)
|
58
58
|
end
|
@@ -61,9 +61,9 @@ class TestClient < MosquittoTestCase
|
|
61
61
|
client = Mosquitto::Client.new
|
62
62
|
assert client.loop_start
|
63
63
|
assert_raises TypeError do
|
64
|
-
client.connect_bind("localhost", TEST_PORT,
|
64
|
+
client.connect_bind("localhost", TEST_PORT, TIMEOUT, :invalid)
|
65
65
|
end
|
66
|
-
assert client.connect_bind(TEST_HOST, TEST_PORT,
|
66
|
+
assert client.connect_bind(TEST_HOST, TEST_PORT, TIMEOUT, "0.0.0.0")
|
67
67
|
ensure
|
68
68
|
client.loop_stop(true)
|
69
69
|
end
|
@@ -72,9 +72,9 @@ class TestClient < MosquittoTestCase
|
|
72
72
|
client = Mosquitto::Client.new
|
73
73
|
assert client.loop_start
|
74
74
|
assert_raises TypeError do
|
75
|
-
client.connect_async(:invalid, TEST_PORT,
|
75
|
+
client.connect_async(:invalid, TEST_PORT, TIMEOUT)
|
76
76
|
end
|
77
|
-
assert client.connect_async(TEST_HOST, TEST_PORT,
|
77
|
+
assert client.connect_async(TEST_HOST, TEST_PORT, TIMEOUT)
|
78
78
|
client.wait_readable
|
79
79
|
assert client.socket != -1
|
80
80
|
ensure
|
@@ -85,9 +85,9 @@ class TestClient < MosquittoTestCase
|
|
85
85
|
client = Mosquitto::Client.new
|
86
86
|
assert client.loop_start
|
87
87
|
assert_raises TypeError do
|
88
|
-
client.connect_bind_async(TEST_HOST, TEST_PORT,
|
88
|
+
client.connect_bind_async(TEST_HOST, TEST_PORT, TIMEOUT, :invalid)
|
89
89
|
end
|
90
|
-
assert client.connect_bind_async(TEST_HOST, TEST_PORT,
|
90
|
+
assert client.connect_bind_async(TEST_HOST, TEST_PORT, TIMEOUT, '0.0.0.0')
|
91
91
|
client.wait_readable
|
92
92
|
assert client.socket != -1
|
93
93
|
ensure
|
@@ -100,7 +100,8 @@ class TestClient < MosquittoTestCase
|
|
100
100
|
assert_raises Mosquitto::Error do
|
101
101
|
client.disconnect
|
102
102
|
end
|
103
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
103
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
104
|
+
client.wait_readable
|
104
105
|
assert client.disconnect
|
105
106
|
ensure
|
106
107
|
client.loop_stop(true)
|
@@ -111,7 +112,8 @@ class TestClient < MosquittoTestCase
|
|
111
112
|
assert_raises Mosquitto::Error do
|
112
113
|
client.reconnect
|
113
114
|
end
|
114
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
115
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
116
|
+
client.wait_readable
|
115
117
|
assert client.reconnect
|
116
118
|
end
|
117
119
|
|
data/test/test_custom_logger.rb
CHANGED
@@ -16,9 +16,11 @@ class TestCustomLogger < MosquittoTestCase
|
|
16
16
|
|
17
17
|
client.logger = logger
|
18
18
|
client.loop_start
|
19
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
20
|
-
assert client.subscribe(nil, "custom_logger", Mosquitto::AT_MOST_ONCE)
|
19
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
21
20
|
client.wait_readable
|
21
|
+
assert client.subscribe(nil, "custom_logger", Mosquitto::AT_MOST_ONCE)
|
22
|
+
|
23
|
+
sleep 2
|
22
24
|
|
23
25
|
logs = log_dev.string
|
24
26
|
assert_match(/DEBUG/, logs)
|
@@ -26,5 +28,8 @@ class TestCustomLogger < MosquittoTestCase
|
|
26
28
|
assert_match(/sending SUBSCRIBE/, logs)
|
27
29
|
assert_match(/custom_logger/, logs)
|
28
30
|
assert_match(/Client mosq/, logs)
|
31
|
+
|
32
|
+
ensure
|
33
|
+
client.loop_stop(true)
|
29
34
|
end
|
30
35
|
end
|
data/test/test_integration.rb
CHANGED
@@ -10,6 +10,7 @@ class TestIntegration < MosquittoTestCase
|
|
10
10
|
CLIENT_IDS = %w(test_integration test_lwt test_clean_session test_duplicate)
|
11
11
|
|
12
12
|
def setup
|
13
|
+
super
|
13
14
|
@result = nil
|
14
15
|
@client = nil
|
15
16
|
connected = false
|
@@ -22,16 +23,21 @@ class TestIntegration < MosquittoTestCase
|
|
22
23
|
@client.on_message do |msg|
|
23
24
|
@result = msg.to_s
|
24
25
|
end
|
25
|
-
assert @client.connect(TEST_HOST, TEST_PORT,
|
26
|
+
assert @client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
26
27
|
wait{ connected }
|
27
28
|
end
|
28
29
|
|
29
30
|
def teardown
|
31
|
+
super
|
30
32
|
disconnected, connected = false, false
|
31
33
|
@client.on_disconnect do |rc|
|
32
34
|
disconnected = true
|
33
35
|
end
|
34
|
-
|
36
|
+
begin
|
37
|
+
@client.disconnect
|
38
|
+
rescue Mosquitto::Error
|
39
|
+
disconnected = true
|
40
|
+
end
|
35
41
|
wait{ disconnected }
|
36
42
|
@client.loop_stop(true)
|
37
43
|
|
@@ -43,9 +49,13 @@ class TestIntegration < MosquittoTestCase
|
|
43
49
|
disconnected = true
|
44
50
|
end
|
45
51
|
client.on_connect do |rc|
|
46
|
-
|
52
|
+
begin
|
53
|
+
assert client.disconnect
|
54
|
+
rescue Mosquitto::Error
|
55
|
+
disconnected = true
|
56
|
+
end
|
47
57
|
end
|
48
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
58
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
49
59
|
wait{ disconnected }
|
50
60
|
client.loop_stop(true)
|
51
61
|
end
|
@@ -60,7 +70,7 @@ class TestIntegration < MosquittoTestCase
|
|
60
70
|
assert client.publish(nil, msg.topic, "", Mosquitto::AT_LEAST_ONCE, true)
|
61
71
|
end
|
62
72
|
end
|
63
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
73
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
64
74
|
wait{ connected }
|
65
75
|
|
66
76
|
TOPICS.each do |topic|
|
@@ -68,8 +78,11 @@ class TestIntegration < MosquittoTestCase
|
|
68
78
|
end
|
69
79
|
|
70
80
|
sleep 5
|
71
|
-
|
72
|
-
|
81
|
+
begin
|
82
|
+
client.disconnect
|
83
|
+
client.loop_stop(true)
|
84
|
+
rescue Mosquitto::Error
|
85
|
+
end
|
73
86
|
end
|
74
87
|
|
75
88
|
def test_basic
|
@@ -424,7 +437,7 @@ class TestIntegration < MosquittoTestCase
|
|
424
437
|
assert @client.subscribe(nil, "a/+/#", Mosquitto::AT_MOST_ONCE)
|
425
438
|
assert @client.subscribe(nil, "#", Mosquitto::AT_MOST_ONCE)
|
426
439
|
|
427
|
-
sleep
|
440
|
+
sleep 3
|
428
441
|
|
429
442
|
@result = nil
|
430
443
|
expected = "should get everything"
|
@@ -476,14 +489,14 @@ class TestIntegration < MosquittoTestCase
|
|
476
489
|
client1.loop_stop(true)
|
477
490
|
client2.loop_stop(true)
|
478
491
|
end
|
479
|
-
client1.connect(TEST_HOST, TEST_PORT,
|
492
|
+
client1.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
480
493
|
|
481
494
|
client1.wait_readable
|
482
495
|
|
483
496
|
client2 = Mosquitto::Client.new("test_duplicate")
|
484
497
|
client2.loop_start
|
485
498
|
client2.logger = Logger.new(STDOUT)
|
486
|
-
client2.connect(TEST_HOST, TEST_PORT,
|
499
|
+
client2.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
487
500
|
|
488
501
|
client2.wait_readable
|
489
502
|
|
@@ -496,7 +509,7 @@ class TestIntegration < MosquittoTestCase
|
|
496
509
|
client1.logger = Logger.new(STDOUT)
|
497
510
|
client1.loop_start
|
498
511
|
client1.will_set("l/w/t", "This is an LWT", Mosquitto::AT_LEAST_ONCE, false)
|
499
|
-
client1.connect(TEST_HOST, TEST_PORT,
|
512
|
+
client1.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
500
513
|
|
501
514
|
assert client1.subscribe(nil, "a/b/c", Mosquitto::AT_LEAST_ONCE)
|
502
515
|
|
@@ -507,7 +520,7 @@ class TestIntegration < MosquittoTestCase
|
|
507
520
|
|
508
521
|
client1.on_disconnect do |rc|
|
509
522
|
assert @client.publish(nil, "a/b/c", expected, Mosquitto::AT_LEAST_ONCE, false)
|
510
|
-
client1.connect(TEST_HOST, TEST_PORT,
|
523
|
+
client1.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
511
524
|
end
|
512
525
|
|
513
526
|
client1.disconnect
|
@@ -515,6 +528,7 @@ class TestIntegration < MosquittoTestCase
|
|
515
528
|
sleep 1
|
516
529
|
|
517
530
|
assert_nil @result
|
531
|
+
client1.loop_stop(true)
|
518
532
|
end
|
519
533
|
|
520
534
|
def test_retain
|
@@ -532,7 +546,7 @@ class TestIntegration < MosquittoTestCase
|
|
532
546
|
client1.on_message do |msg|
|
533
547
|
result = msg.to_s
|
534
548
|
end
|
535
|
-
client1.connect(TEST_HOST, TEST_PORT,
|
549
|
+
client1.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
536
550
|
client1.wait_readable
|
537
551
|
|
538
552
|
assert client1.subscribe(nil, "a/b/c", Mosquitto::AT_LEAST_ONCE)
|
@@ -547,25 +561,37 @@ class TestIntegration < MosquittoTestCase
|
|
547
561
|
result = nil
|
548
562
|
# clear retained message
|
549
563
|
assert @client.publish(nil, "a/b/c", "", Mosquitto::AT_LEAST_ONCE, true)
|
564
|
+
|
565
|
+
client1.loop_stop(true)
|
550
566
|
end
|
551
567
|
|
552
568
|
def test_lwt
|
553
|
-
|
569
|
+
connected = false
|
570
|
+
assert @client.subscribe(nil, "will/topic", Mosquitto::AT_LEAST_ONCE)
|
571
|
+
|
572
|
+
sleep 1
|
554
573
|
|
555
574
|
will = "This is an LWT"
|
556
575
|
client1 = Mosquitto::Client.new("test_lwt")
|
557
576
|
client1.logger = Logger.new(STDOUT)
|
558
577
|
client1.loop_start
|
578
|
+
sleep 1
|
559
579
|
client1.will_set("will/topic", will, Mosquitto::AT_LEAST_ONCE, false)
|
580
|
+
sleep 1
|
560
581
|
client1.on_connect do |rc|
|
561
|
-
|
562
|
-
client1.loop_stop(true)
|
582
|
+
connected = true
|
563
583
|
end
|
564
|
-
client1.connect(TEST_HOST, TEST_PORT,
|
584
|
+
client1.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
565
585
|
|
566
|
-
|
586
|
+
wait{ connected }
|
587
|
+
|
588
|
+
sleep 5
|
589
|
+
|
590
|
+
IO.for_fd(client1.socket).close
|
591
|
+
client1.destroy
|
592
|
+
|
593
|
+
sleep 5
|
567
594
|
|
568
|
-
@result = nil
|
569
595
|
wait{ @result }
|
570
596
|
assert_equal will, @result
|
571
597
|
end
|
data/test/test_loops.rb
CHANGED
@@ -5,11 +5,13 @@ require File.join(File.dirname(__FILE__), 'helper')
|
|
5
5
|
class TestLoops < MosquittoTestCase
|
6
6
|
def test_socket
|
7
7
|
client = Mosquitto::Client.new
|
8
|
+
client.loop_start
|
8
9
|
assert_equal(-1, client.socket)
|
9
10
|
assert client.socket == -1
|
10
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
11
|
-
assert_instance_of Fixnum, client.socket
|
11
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
12
12
|
client.wait_readable
|
13
|
+
|
14
|
+
assert_instance_of Fixnum, client.socket
|
13
15
|
assert client.socket != -1
|
14
16
|
end
|
15
17
|
|
@@ -18,15 +20,17 @@ class TestLoops < MosquittoTestCase
|
|
18
20
|
assert_raises Mosquitto::Error do
|
19
21
|
client.loop(10,10)
|
20
22
|
end
|
21
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
22
|
-
assert client.publish(nil, "loop", "test", Mosquitto::AT_MOST_ONCE, true)
|
23
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
23
24
|
assert client.loop(10,10)
|
25
|
+
client.wait_readable
|
26
|
+
|
27
|
+
assert client.publish(nil, "loop", "test", Mosquitto::AT_MOST_ONCE, true)
|
24
28
|
end
|
25
29
|
|
26
30
|
def test_loop_forever
|
27
31
|
connected = false
|
32
|
+
client = Mosquitto::Client.new
|
28
33
|
Thread.new do
|
29
|
-
client = Mosquitto::Client.new
|
30
34
|
client.on_connect do |rc|
|
31
35
|
connected = true
|
32
36
|
Thread.current.kill
|
@@ -34,23 +38,31 @@ class TestLoops < MosquittoTestCase
|
|
34
38
|
assert_raises TypeError do
|
35
39
|
client.loop_forever(:invalid,1)
|
36
40
|
end
|
37
|
-
assert client.connect(TEST_HOST, 1883,
|
41
|
+
assert client.connect(TEST_HOST, 1883, TIMEOUT)
|
42
|
+
|
38
43
|
assert client.loop_forever(-1,1)
|
39
|
-
end.join(
|
44
|
+
end.join(2)
|
45
|
+
client.wait_readable
|
40
46
|
assert connected
|
41
47
|
end
|
42
48
|
|
43
49
|
def test_loop_stop_start
|
44
50
|
client = Mosquitto::Client.new
|
45
|
-
assert client.connect(TEST_HOST, TEST_PORT, 10)
|
46
|
-
assert client.publish(nil, "loop_stop_start", "test", Mosquitto::AT_MOST_ONCE, true)
|
47
51
|
assert client.loop_start
|
52
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
53
|
+
client.wait_readable
|
54
|
+
|
55
|
+
assert client.publish(nil, "loop_stop_start", "test", Mosquitto::AT_MOST_ONCE, true)
|
56
|
+
sleep 1
|
48
57
|
assert client.loop_stop(true)
|
49
58
|
end
|
50
59
|
|
51
60
|
def test_want_write_p
|
52
61
|
client = Mosquitto::Client.new
|
53
|
-
|
62
|
+
client.loop_start
|
63
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
64
|
+
client.wait_readable
|
65
|
+
|
54
66
|
assert !client.want_write?
|
55
67
|
end
|
56
68
|
end
|
data/test/test_mosquitto.rb
CHANGED
data/test/test_pub_sub.rb
CHANGED
@@ -5,10 +5,13 @@ require File.join(File.dirname(__FILE__), 'helper')
|
|
5
5
|
class TestPubSub < MosquittoTestCase
|
6
6
|
def test_publish
|
7
7
|
client = Mosquitto::Client.new
|
8
|
+
client.loop_start
|
8
9
|
assert_raises Mosquitto::Error do
|
9
10
|
client.publish(nil, "publish", "test", Mosquitto::AT_MOST_ONCE, true)
|
10
11
|
end
|
11
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
12
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
13
|
+
client.wait_readable
|
14
|
+
|
12
15
|
assert_raises TypeError do
|
13
16
|
client.publish(nil, :invalid, "test", Mosquitto::AT_MOST_ONCE, true)
|
14
17
|
end
|
@@ -18,33 +21,44 @@ class TestPubSub < MosquittoTestCase
|
|
18
21
|
|
19
22
|
def test_subscribe
|
20
23
|
client = Mosquitto::Client.new
|
24
|
+
client.loop_start
|
21
25
|
assert_raises Mosquitto::Error do
|
22
26
|
client.subscribe(nil, "subscribe", Mosquitto::AT_MOST_ONCE)
|
23
27
|
end
|
24
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
28
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
29
|
+
client.wait_readable
|
30
|
+
|
25
31
|
assert_raises TypeError do
|
26
32
|
client.subscribe(nil, :topic, Mosquitto::AT_MOST_ONCE)
|
27
33
|
end
|
34
|
+
|
28
35
|
assert client.subscribe(nil, "subscribe", Mosquitto::AT_MOST_ONCE)
|
29
36
|
assert client.subscribe(3, "subscribe", Mosquitto::AT_MOST_ONCE)
|
30
37
|
end
|
31
38
|
|
32
39
|
def test_unsubscribe
|
33
40
|
client = Mosquitto::Client.new
|
41
|
+
client.loop_start
|
34
42
|
assert_raises Mosquitto::Error do
|
35
43
|
client.unsubscribe(nil, "unsubscribe")
|
36
44
|
end
|
37
|
-
assert client.connect(TEST_HOST, TEST_PORT,
|
45
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
46
|
+
client.wait_readable
|
47
|
+
|
38
48
|
assert_raises TypeError do
|
39
49
|
client.unsubscribe(nil, :topic)
|
40
50
|
end
|
51
|
+
|
41
52
|
assert client.unsubscribe(nil, "unsubscribe")
|
42
53
|
assert client.unsubscribe(3, "unsubscribe")
|
43
54
|
end
|
44
55
|
|
45
56
|
def test_subscribe_unsubscribe
|
46
57
|
client = Mosquitto::Client.new
|
47
|
-
|
58
|
+
client.loop_start
|
59
|
+
assert client.connect(TEST_HOST, TEST_PORT, TIMEOUT)
|
60
|
+
client.wait_readable
|
61
|
+
|
48
62
|
assert client.subscribe(nil, "subscribe_unsubscribe", Mosquitto::AT_MOST_ONCE)
|
49
63
|
assert client.unsubscribe(nil, "subscribe_unsubscribe")
|
50
64
|
end
|