@@ -25,7 +25,7 @@ import "testing"
25
25
26
26
func Test_Start (t * testing.T ) {
27
27
ops := NewClientOptions ().SetClientId ("Start" ).
28
- SetBroker (FVT_TCP ).
28
+ AddBroker (FVT_TCP ).
29
29
SetStore (NewFileStore ("/tmp/fvt/Start" ))
30
30
c := NewClient (ops )
31
31
@@ -40,7 +40,7 @@ func Test_Start(t *testing.T) {
40
40
/* uncomment this if you have connection policy disallowing FailClientID
41
41
func Test_InvalidConnRc(t *testing.T) {
42
42
ops := NewClientOptions().SetClientId("FailClientID").
43
- SetBroker ("tcp://" + FVT_IP + ":17003").
43
+ AddBroker ("tcp://" + FVT_IP + ":17003").
44
44
SetStore(NewFileStore("/tmp/fvt/InvalidConnRc"))
45
45
46
46
c := NewClient(ops)
@@ -78,7 +78,7 @@ func NewTlsConfig() *tls.Config {
78
78
func Test_Start_Ssl(t *testing.T) {
79
79
tlsconfig := NewTlsConfig()
80
80
ops := NewClientOptions().SetClientId("StartSsl").
81
- SetBroker (FVT_SSL).
81
+ AddBroker (FVT_SSL).
82
82
SetStore(NewFileStore("/tmp/fvt/Start_Ssl")).
83
83
SetTlsConfig(tlsconfig)
84
84
@@ -95,7 +95,7 @@ func Test_Start_Ssl(t *testing.T) {
95
95
96
96
func Test_Publish_1 (t * testing.T ) {
97
97
ops := NewClientOptions ()
98
- ops .SetBroker (FVT_TCP )
98
+ ops .AddBroker (FVT_TCP )
99
99
ops .SetClientId ("Publish_1" )
100
100
ops .SetStore (NewFileStore ("/tmp/fvt/Publish_1" ))
101
101
@@ -112,7 +112,7 @@ func Test_Publish_1(t *testing.T) {
112
112
113
113
func Test_Publish_2 (t * testing.T ) {
114
114
ops := NewClientOptions ()
115
- ops .SetBroker (FVT_TCP )
115
+ ops .AddBroker (FVT_TCP )
116
116
ops .SetClientId ("Publish_2" )
117
117
ops .SetStore (NewFileStore ("/tmp/fvt/Publish_2" ))
118
118
@@ -130,7 +130,7 @@ func Test_Publish_2(t *testing.T) {
130
130
131
131
func Test_Publish_3 (t * testing.T ) {
132
132
ops := NewClientOptions ()
133
- ops .SetBroker (FVT_TCP )
133
+ ops .AddBroker (FVT_TCP )
134
134
ops .SetClientId ("Publish_3" )
135
135
ops .SetStore (NewFileStore ("/tmp/fvt/Publish_3" ))
136
136
@@ -149,13 +149,13 @@ func Test_Publish_3(t *testing.T) {
149
149
150
150
func Test_Subscribe (t * testing.T ) {
151
151
pops := NewClientOptions ()
152
- pops .SetBroker (FVT_TCP )
152
+ pops .AddBroker (FVT_TCP )
153
153
pops .SetClientId ("Subscribe_tx" )
154
154
pops .SetStore (NewFileStore ("/tmp/fvt/Subscribe/p" ))
155
155
p := NewClient (pops )
156
156
157
157
sops := NewClientOptions ()
158
- sops .SetBroker (FVT_TCP )
158
+ sops .AddBroker (FVT_TCP )
159
159
sops .SetClientId ("Subscribe_rx" )
160
160
sops .SetStore (NewFileStore ("/tmp/fvt/Subscribe/s" ))
161
161
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -187,7 +187,7 @@ func Test_Subscribe(t *testing.T) {
187
187
func Test_Will (t * testing.T ) {
188
188
willmsgc := make (chan string )
189
189
190
- sops := NewClientOptions ().SetBroker (FVT_TCP )
190
+ sops := NewClientOptions ().AddBroker (FVT_TCP )
191
191
sops .SetClientId ("will-giver" )
192
192
sops .SetWill ("/wills" , "good-byte!" , QOS_ZERO , false )
193
193
sops .SetOnConnectionLost (func (client * MqttClient , err error ) {
@@ -196,7 +196,7 @@ func Test_Will(t *testing.T) {
196
196
c := NewClient (sops )
197
197
198
198
wops := NewClientOptions ()
199
- wops .SetBroker (FVT_TCP )
199
+ wops .AddBroker (FVT_TCP )
200
200
wops .SetClientId ("will-subscriber" )
201
201
wops .SetStore (NewFileStore ("/tmp/fvt/Will" ))
202
202
wops .SetDefaultPublishHandler (func (client * MqttClient , msg Message ) {
@@ -238,14 +238,14 @@ func Test_Binary_Will(t *testing.T) {
238
238
0xEF ,
239
239
}
240
240
241
- sops := NewClientOptions ().SetBroker (FVT_TCP )
241
+ sops := NewClientOptions ().AddBroker (FVT_TCP )
242
242
sops .SetClientId ("will-giver" )
243
243
sops .SetBinaryWill ("/wills" , will , QOS_ZERO , false )
244
244
sops .SetOnConnectionLost (func (client * MqttClient , err error ) {
245
245
})
246
246
c := NewClient (sops )
247
247
248
- wops := NewClientOptions ().SetBroker (FVT_TCP )
248
+ wops := NewClientOptions ().AddBroker (FVT_TCP )
249
249
wops .SetClientId ("will-subscriber" )
250
250
wops .SetStore (NewFileStore ("/tmp/fvt/Binary_Will" ))
251
251
wops .SetDefaultPublishHandler (func (client * MqttClient , msg Message ) {
@@ -302,13 +302,13 @@ func Test_p0s0(t *testing.T) {
302
302
choke := make (chan bool )
303
303
304
304
pops := NewClientOptions ()
305
- pops .SetBroker (FVT_TCP )
305
+ pops .AddBroker (FVT_TCP )
306
306
pops .SetClientId ("p0s0-pub" )
307
307
pops .SetStore (NewFileStore (store + "/p" ))
308
308
p := NewClient (pops )
309
309
310
310
sops := NewClientOptions ()
311
- sops .SetBroker (FVT_TCP )
311
+ sops .AddBroker (FVT_TCP )
312
312
sops .SetClientId ("p0s0-sub" )
313
313
sops .SetStore (NewFileStore (store + "/s" ))
314
314
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -362,13 +362,13 @@ func Test_p0s1(t *testing.T) {
362
362
choke := make (chan bool )
363
363
364
364
pops := NewClientOptions ()
365
- pops .SetBroker (FVT_TCP )
365
+ pops .AddBroker (FVT_TCP )
366
366
pops .SetClientId ("p0s1-pub" )
367
367
pops .SetStore (NewFileStore (store + "/p" ))
368
368
p := NewClient (pops )
369
369
370
370
sops := NewClientOptions ()
371
- sops .SetBroker (FVT_TCP )
371
+ sops .AddBroker (FVT_TCP )
372
372
sops .SetClientId ("p0s1-sub" )
373
373
sops .SetStore (NewFileStore (store + "/s" ))
374
374
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -421,13 +421,13 @@ func Test_p0s2(t *testing.T) {
421
421
choke := make (chan bool )
422
422
423
423
pops := NewClientOptions ()
424
- pops .SetBroker (FVT_TCP )
424
+ pops .AddBroker (FVT_TCP )
425
425
pops .SetClientId ("p0s2-pub" )
426
426
pops .SetStore (NewFileStore (store + "/p" ))
427
427
p := NewClient (pops )
428
428
429
429
sops := NewClientOptions ()
430
- sops .SetBroker (FVT_TCP )
430
+ sops .AddBroker (FVT_TCP )
431
431
sops .SetClientId ("p0s2-sub" )
432
432
sops .SetStore (NewFileStore (store + "/s" ))
433
433
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -480,13 +480,13 @@ func Test_p1s0(t *testing.T) {
480
480
choke := make (chan bool )
481
481
482
482
pops := NewClientOptions ()
483
- pops .SetBroker (FVT_TCP )
483
+ pops .AddBroker (FVT_TCP )
484
484
pops .SetClientId ("p1s0-pub" )
485
485
pops .SetStore (NewFileStore (store + "/p" ))
486
486
p := NewClient (pops )
487
487
488
488
sops := NewClientOptions ()
489
- sops .SetBroker (FVT_TCP )
489
+ sops .AddBroker (FVT_TCP )
490
490
sops .SetClientId ("p1s0-sub" )
491
491
sops .SetStore (NewFileStore (store + "/s" ))
492
492
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -539,13 +539,13 @@ func Test_p1s1(t *testing.T) {
539
539
choke := make (chan bool )
540
540
541
541
pops := NewClientOptions ()
542
- pops .SetBroker (FVT_TCP )
542
+ pops .AddBroker (FVT_TCP )
543
543
pops .SetClientId ("p1s1-pub" )
544
544
pops .SetStore (NewFileStore (store + "/p" ))
545
545
p := NewClient (pops )
546
546
547
547
sops := NewClientOptions ()
548
- sops .SetBroker (FVT_TCP )
548
+ sops .AddBroker (FVT_TCP )
549
549
sops .SetClientId ("p1s1-sub" )
550
550
sops .SetStore (NewFileStore (store + "/s" ))
551
551
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -598,13 +598,13 @@ func Test_p1s2(t *testing.T) {
598
598
choke := make (chan bool )
599
599
600
600
pops := NewClientOptions ()
601
- pops .SetBroker (FVT_TCP )
601
+ pops .AddBroker (FVT_TCP )
602
602
pops .SetClientId ("p1s2-pub" )
603
603
pops .SetStore (NewFileStore (store + "/p" ))
604
604
p := NewClient (pops )
605
605
606
606
sops := NewClientOptions ()
607
- sops .SetBroker (FVT_TCP )
607
+ sops .AddBroker (FVT_TCP )
608
608
sops .SetClientId ("p1s2-sub" )
609
609
sops .SetStore (NewFileStore (store + "/s" ))
610
610
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -656,13 +656,13 @@ func Test_p2s0(t *testing.T) {
656
656
choke := make (chan bool )
657
657
658
658
pops := NewClientOptions ()
659
- pops .SetBroker (FVT_TCP )
659
+ pops .AddBroker (FVT_TCP )
660
660
pops .SetClientId ("p2s0-pub" )
661
661
pops .SetStore (NewFileStore (store + "/p" ))
662
662
p := NewClient (pops )
663
663
664
664
sops := NewClientOptions ()
665
- sops .SetBroker (FVT_TCP )
665
+ sops .AddBroker (FVT_TCP )
666
666
sops .SetClientId ("p2s0-sub" )
667
667
sops .SetStore (NewFileStore (store + "/s" ))
668
668
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -712,13 +712,13 @@ func Test_p2s1(t *testing.T) {
712
712
choke := make (chan bool )
713
713
714
714
pops := NewClientOptions ()
715
- pops .SetBroker (FVT_TCP )
715
+ pops .AddBroker (FVT_TCP )
716
716
pops .SetClientId ("p2s1-pub" )
717
717
pops .SetStore (NewFileStore (store + "/p" ))
718
718
p := NewClient (pops )
719
719
720
720
sops := NewClientOptions ()
721
- sops .SetBroker (FVT_TCP )
721
+ sops .AddBroker (FVT_TCP )
722
722
sops .SetClientId ("p2s1-sub" )
723
723
sops .SetStore (NewFileStore (store + "/s" ))
724
724
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -771,13 +771,13 @@ func Test_p2s2(t *testing.T) {
771
771
choke := make (chan bool )
772
772
773
773
pops := NewClientOptions ()
774
- pops .SetBroker (FVT_TCP )
774
+ pops .AddBroker (FVT_TCP )
775
775
pops .SetClientId ("p2s2-pub" )
776
776
pops .SetStore (NewFileStore (store + "/p" ))
777
777
p := NewClient (pops )
778
778
779
779
sops := NewClientOptions ()
780
- sops .SetBroker (FVT_TCP )
780
+ sops .AddBroker (FVT_TCP )
781
781
sops .SetClientId ("p2s2-sub" )
782
782
sops .SetStore (NewFileStore (store + "/s" ))
783
783
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -828,13 +828,13 @@ func Test_PublishMessage(t *testing.T) {
828
828
choke := make (chan bool )
829
829
830
830
pops := NewClientOptions ()
831
- pops .SetBroker (FVT_TCP )
831
+ pops .AddBroker (FVT_TCP )
832
832
pops .SetClientId ("pubmsg-pub" )
833
833
pops .SetStore (NewFileStore (store + "/p" ))
834
834
p := NewClient (pops )
835
835
836
836
sops := NewClientOptions ()
837
- sops .SetBroker (FVT_TCP )
837
+ sops .AddBroker (FVT_TCP )
838
838
sops .SetClientId ("pubmsg-sub" )
839
839
sops .SetStore (NewFileStore (store + "/s" ))
840
840
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -888,13 +888,13 @@ func Test_PublishEmptyMessage(t *testing.T) {
888
888
choke := make (chan bool )
889
889
890
890
pops := NewClientOptions ()
891
- pops .SetBroker (FVT_TCP )
891
+ pops .AddBroker (FVT_TCP )
892
892
pops .SetClientId ("pubmsgempty-pub" )
893
893
pops .SetStore (NewFileStore (store + "/p" ))
894
894
p := NewClient (pops )
895
895
896
896
sops := NewClientOptions ()
897
- sops .SetBroker (FVT_TCP )
897
+ sops .AddBroker (FVT_TCP )
898
898
sops .SetClientId ("pubmsgempty-sub" )
899
899
sops .SetStore (NewFileStore (store + "/s" ))
900
900
var f MessageHandler = func (client * MqttClient , msg Message ) {
@@ -942,14 +942,14 @@ func Test_Cleanstore(t *testing.T) {
942
942
topic := "/test/cleanstore"
943
943
944
944
pops := NewClientOptions ()
945
- pops .SetBroker (FVT_TCP )
945
+ pops .AddBroker (FVT_TCP )
946
946
pops .SetClientId ("cleanstore-pub" )
947
947
pops .SetStore (NewFileStore (store + "/p" ))
948
948
p := NewClient (pops )
949
949
950
950
var s * MqttClient
951
951
sops := NewClientOptions ()
952
- sops .SetBroker (FVT_TCP )
952
+ sops .AddBroker (FVT_TCP )
953
953
sops .SetClientId ("cleanstore-sub" )
954
954
sops .SetCleanSession (false )
955
955
sops .SetStore (NewFileStore (store + "/s" ))
@@ -994,7 +994,7 @@ func Test_Cleanstore(t *testing.T) {
994
994
p .Disconnect (250 )
995
995
996
996
sops = NewClientOptions ()
997
- sops .SetBroker (FVT_TCP )
997
+ sops .AddBroker (FVT_TCP )
998
998
sops .SetClientId ("cleanstore-sub" )
999
999
sops .SetCleanSession (true )
1000
1000
sops .SetStore (NewFileStore (store + "/s" ))
@@ -1010,13 +1010,31 @@ func Test_Cleanstore(t *testing.T) {
1010
1010
// how to check?
1011
1011
}
1012
1012
1013
+ func Test_MultipleURLs (t * testing.T ) {
1014
+ ops := NewClientOptions ()
1015
+ ops .AddBroker ("tcp://127.0.0.1:10000" )
1016
+ ops .AddBroker (FVT_TCP )
1017
+ ops .SetClientId ("MutliURL" )
1018
+ ops .SetStore (NewFileStore ("/tmp/fvt/MultiURL" ))
1019
+
1020
+ c := NewClient (ops )
1021
+ _ , err := c .Start ()
1022
+ if err != nil {
1023
+ t .Fatalf ("Error on MqttClient.Start(): %v" , err )
1024
+ }
1025
+
1026
+ c .Publish (QOS_ZERO , "/test/MultiURL" , []byte ("Publish qo0" ))
1027
+
1028
+ c .Disconnect (250 )
1029
+ }
1030
+
1013
1031
/*
1014
1032
// A test to make sure ping mechanism is working
1015
1033
// This test can be left commented out because it's annoying to wait for
1016
1034
func Test_ping3_idle10(t *testing.T) {
1017
1035
ops := NewClientOptions()
1018
- ops.SetBroker (FVT_TCP)
1019
- //ops.SetBroker ("tcp://test.mosquitto.org:1883")
1036
+ ops.AddBroker (FVT_TCP)
1037
+ //ops.AddBroker ("tcp://test.mosquitto.org:1883")
1020
1038
ops.SetClientId("p3i10")
1021
1039
ops.SetTimeout(4)
1022
1040
0 commit comments