forked from gmallard/stompngo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wrsubrduns_test.go
91 lines (86 loc) · 2.39 KB
/
wrsubrduns_test.go
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
//
// Copyright © 2011-2014 Guy M. Allard
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package stompngo
import (
"os"
"testing"
)
/*
Test a Stomp 1.1+ shovel.
*/
func TestShovel11(t *testing.T) {
if os.Getenv("STOMP_TEST11p") == "" {
t.Skip("Test11Shovel norun, need 1.1+")
}
t.Parallel()
n, _ := openConn(t)
ch := check11(TEST_HEADERS)
c, _ := Connect(n, ch)
//
m := "A message"
d := "/queue/subunsub.shovel.01"
h := Headers{"destination", d,
"dupkey1", "value0",
"dupkey1", "value1",
"dupkey1", "value2"}
_ = c.Send(h, m)
//
h = Headers{"destination", d, "id", d}
s, e := c.Subscribe(h)
if e != nil {
t.Errorf("Expected no subscribe error, got [%v]\n", e)
}
if s == nil {
t.Errorf("Expected subscribe channel, got [nil]\n")
}
md := <-s // Read message data
//
if md.Error != nil {
t.Errorf("Expected no message data error, got [%v]\n", md.Error)
}
msg := md.Message
rd := msg.Headers.Value("destination")
if rd != d {
t.Errorf("Expected destination [%v], got [%v]\n", d, rd)
}
ri := msg.Headers.Value("subscription")
if ri != d {
t.Errorf("Expected subscription [%v], got [%v]\n", d, ri)
}
// All servers MUST do this
// This assumes that AMQ is at least 5.7.0. AMQ 5.6.0 is broken in this regard.
if !msg.Headers.ContainsKV("dupkey1", "value0") {
t.Errorf("Expected true for [%v], [%v]\n", "dupkey1", "value0")
}
// Some servers MAY do this. Apollo is one that does.
if os.Getenv("STOMP_APOLLO") != "" {
if !msg.Headers.ContainsKV("dupkey1", "value1") {
t.Errorf("Expected true for [%v], [%v]\n", "dupkey1", "value1")
}
if !msg.Headers.ContainsKV("dupkey1", "value2") {
t.Errorf("Expected true for [%v], [%v]\n", "dupkey1", "value2")
}
}
//
uh := Headers{"id", ri, "destination", d}
e = c.Unsubscribe(uh)
if e != nil {
t.Errorf("Expected no unsubscribe error, got [%v]\n", e)
}
//
_ = c.Disconnect(empty_headers)
_ = closeConn(t, n)
}