121 lines
4.3 KiB
Go
121 lines
4.3 KiB
Go
package internal
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
|
||
|
|
"github.com/stretchr/testify/assert"
|
||
|
|
)
|
||
|
|
|
||
|
|
const (
|
||
|
|
SendEsp = `<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
|
||
|
|
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
||
|
|
|
||
|
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||
|
|
|
||
|
|
<soap:Header>
|
||
|
|
|
||
|
|
<BHIA_CIIMS:AuthenticationToken xmlns:BHIA_CIIMS="http://ciims.bhia.itdcl.com/ExchangeService">
|
||
|
|
|
||
|
|
<BHIA_CIIMS:Username xmlns:BHIA_CIIMS="http://ciims.bhia.itdcl.com/ExchangeService">FIMS</BHIA_CIIMS:Username>
|
||
|
|
|
||
|
|
<BHIA_CIIMS:Password xmlns:BHIA_CIIMS="http://ciims.bhia.itdcl.com/ExchangeService">FIMSPASS</BHIA_CIIMS:Password>
|
||
|
|
|
||
|
|
</BHIA_CIIMS:AuthenticationToken>
|
||
|
|
|
||
|
|
</soap:Header>
|
||
|
|
|
||
|
|
<soap:Body>
|
||
|
|
|
||
|
|
<ns1:send xmlns:ns1="http://ciims.bhia.itdcl.com/ExchangeService">
|
||
|
|
|
||
|
|
<ns1:in0><MSG/></ns1:in0>
|
||
|
|
|
||
|
|
<ns2:in1 xmlns="http://msg.ciims.bhia.itdcl.com" xmlns:ns2="http://ciims.bhia.itdcl.com/ExchangeService">
|
||
|
|
|
||
|
|
<ack>false</ack>
|
||
|
|
|
||
|
|
<priority>1</priority>
|
||
|
|
|
||
|
|
<routeId>FLOP-CHDT-ORMS-FIMS</routeId>
|
||
|
|
|
||
|
|
<valXml>false</valXml>
|
||
|
|
|
||
|
|
</ns2:in1>
|
||
|
|
|
||
|
|
</ns1:send>
|
||
|
|
|
||
|
|
</soap:Body>
|
||
|
|
|
||
|
|
</soap:Envelope>
|
||
|
|
`
|
||
|
|
|
||
|
|
ReceiveEsp = `<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
|
||
|
|
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
||
|
|
|
||
|
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||
|
|
|
||
|
|
<soap:Header>
|
||
|
|
|
||
|
|
<BHIA_CIIMS:AuthenticationToken xmlns:BHIA_CIIMS="http://ciims.bhia.itdcl.com/ExchangeService">
|
||
|
|
|
||
|
|
<BHIA_CIIMS:Username xmlns:BHIA_CIIMS="http://ciims.bhia.itdcl.com/ExchangeService">FIMS</BHIA_CIIMS:Username>
|
||
|
|
|
||
|
|
<BHIA_CIIMS:Password xmlns:BHIA_CIIMS="http://ciims.bhia.itdcl.com/ExchangeService">FIMSPASS</BHIA_CIIMS:Password>
|
||
|
|
|
||
|
|
</BHIA_CIIMS:AuthenticationToken>
|
||
|
|
|
||
|
|
</soap:Header>
|
||
|
|
|
||
|
|
<soap:Body>
|
||
|
|
|
||
|
|
<ns1:receive xmlns:ns1="http://ciims.bhia.itdcl.com/ExchangeService">
|
||
|
|
|
||
|
|
<ns1:in0>2</ns1:in0>
|
||
|
|
|
||
|
|
</ns1:receive>
|
||
|
|
|
||
|
|
</soap:Body>
|
||
|
|
|
||
|
|
</soap:Envelope>
|
||
|
|
`
|
||
|
|
ReceiveResp string = `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||
|
|
<soap:Body>
|
||
|
|
<ns1:receiveResponse xmlns:ns1="http://ciims.bhia.itdcl.com/ExchangeService">
|
||
|
|
<ns1:out>
|
||
|
|
<ns1:string><?xml version="1.0" encoding="UTF-8"?> <msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="unisysaodbsis.xsd"> <meta> <sndr>AODB</sndr> <seqn>820830</seqn> <dttm>20180527124442</dttm> <type>FLOP</type> <styp>ESTT</styp> </meta> <flop> <flid>10725849</flid> <ffid>CA-CA4242-A-27MAY181955-D</ffid> <estt>27MAY181945</estt> </flop> </msg></ns1:string>
|
||
|
|
<ns1:string><?xml version="1.0" encoding="UTF-8"?> <msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="unisysaodbsis.xsd"> <meta> <sndr>AODB</sndr> <seqn>820830</seqn> <dttm>20180527124442</dttm> <type>FLOP</type> <styp>ESTT</styp> </meta> <flop> <flid>10725849</flid> <ffid>CA-CA4242-A-27MAY181955-D</ffid> <estt>27MAY181945</estt> </flop> </msg></ns1:string>
|
||
|
|
</ns1:out>
|
||
|
|
</ns1:receiveResponse>
|
||
|
|
</soap:Body>
|
||
|
|
</soap:Envelope>`
|
||
|
|
|
||
|
|
Msg string = `<?xml version="1.0" encoding="UTF-8"?> <msg xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="unisysaodbsis.xsd"> <meta> <sndr>AODB</sndr> <seqn>820830</seqn> <dttm>20180527124442</dttm> <type>FLOP</type> <styp>ESTT</styp> </meta> <flop> <flid>10725849</flid> <ffid>CA-CA4242-A-27MAY181955-D</ffid> <estt>27MAY181945</estt> </flop> </msg>`
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestSend(t *testing.T) {
|
||
|
|
assert := assert.New(t)
|
||
|
|
// assert equality
|
||
|
|
// assert.Equal(123, 123, "they should be equal")
|
||
|
|
msg := CreateSend("FIMS", "FIMSPASS", 1, "FLOP-CHDT-ORMS-FIMS", false, "<MSG/>")
|
||
|
|
|
||
|
|
// println(msg)
|
||
|
|
assert.Equal(SendEsp, msg, "send post should be equal")
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestReceive(t *testing.T) {
|
||
|
|
assert := assert.New(t)
|
||
|
|
|
||
|
|
msg := CreateReceive("FIMS", "FIMSPASS", 2)
|
||
|
|
|
||
|
|
assert.Equal(ReceiveEsp, msg, "receive post should be equal")
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestGetMsg(t *testing.T) {
|
||
|
|
assert := assert.New(t)
|
||
|
|
msgs := GetMsgs(ReceiveResp)
|
||
|
|
assert.Equal(2, len(msgs), "should get 2 message")
|
||
|
|
assert.Equal(Msg, msgs[0], "message")
|
||
|
|
}
|