2 // Copyright © 2014-2019 Guy M. Allard
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
24 Test Send Basiconn, one message.
26 func TestSendBytesBasic(t
*testing
.T
) {
27 for _
, sp
:= range Protocols() {
30 ch
= headersProtocol(ch
, sp
)
31 conn
, e
= Connect(n
, ch
)
33 t
.Fatalf("TestSendBytesBasic CONNECT expected no error, got [%v]\n", e
)
37 mb
:= []byte("A message-" + sp
)
38 d
:= tdest("/queue/send.basiconn.01.bytes." + sp
)
39 sh
:= Headers
{HK_DESTINATION
, d
}
40 e
= conn
.SendBytes(sh
, mb
)
42 t
.Fatalf("TestSendBytesBasic Expected nil error, got [%v]\n", e
)
45 e
= conn
.SendBytes(empty_headers
, mb
)
47 t
.Fatalf("TestSendBytesBasic Expected error, got [nil]\n")
50 t
.Fatalf("TestSendBytesBasic Expected [%v], got [%v]\n", EREQDSTSND
, e
)
52 checkReceived(t
, conn
, false)
53 e
= conn
.Disconnect(empty_headers
)
54 checkDisconnectError(t
, e
)
60 Test Send Multiple, multiple messages, 5 to be exact.
62 func TestSendBytesMultiple(t
*testing
.T
) {
63 for _
, sp
:= range Protocols() {
66 ch
= headersProtocol(ch
, sp
)
67 conn
, e
= Connect(n
, ch
)
69 t
.Fatalf("TestSendBytesMultiple CONNECT expected no error, got [%v]\n", e
)
72 mdb
:= multi_send_data
{conn
: conn
,
73 dest
: tdest("/queue/sendmultiple.01.bytes." + sp
+ "."),
74 mpref
: "sendmultiple.01.message.prefix.bytes ",
76 e
= sendMultipleBytes(mdb
)
78 t
.Fatalf("TestSendBytesMultiple Expected nil error, got [%v]\n", e
)
81 checkReceived(t
, conn
, false)
82 e
= conn
.Disconnect(empty_headers
)
83 checkDisconnectError(t
, e
)