2024-10-30 18:51:51 +08:00
|
|
|
package search
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
"testing"
|
|
|
|
|
2024-10-31 18:22:47 +08:00
|
|
|
xsd "git.pyer.club/kingecg/goonvif/onvif/xsd"
|
2024-10-30 18:51:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMarshallSummary(t *testing.T) {
|
|
|
|
summary := RecordingSummary{
|
|
|
|
DataFrom: xsd.DateTime("2019-01-01T00:00:00Z"),
|
|
|
|
DataUntil: xsd.DateTime("2019-01-01T00:00:00Z"),
|
|
|
|
NumberRecordings: xsd.Int(1),
|
|
|
|
}
|
|
|
|
b, err := xml.Marshal(summary)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
t.Log(string(b))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUnmarshallSummary(t *testing.T) {
|
|
|
|
data := `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"
|
|
|
|
xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding"
|
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tt="http://www.onvif.org/ver10/schema"
|
|
|
|
xmlns:tds="http://www.onvif.org/ver10/device/wsdl"
|
|
|
|
xmlns:trt="http://www.onvif.org/ver10/media/wsdl"
|
|
|
|
xmlns:timg="http://www.onvif.org/ver20/imaging/wsdl"
|
|
|
|
xmlns:tev="http://www.onvif.org/ver10/events/wsdl"
|
|
|
|
xmlns:tptz="http://www.onvif.org/ver20/ptz/wsdl"
|
|
|
|
xmlns:tan="http://www.onvif.org/ver20/analytics/wsdl"
|
|
|
|
xmlns:tst="http://www.onvif.org/ver10/storage/wsdl" xmlns:ter="http://www.onvif.org/ver10/error"
|
|
|
|
xmlns:dn="http://www.onvif.org/ver10/network/wsdl"
|
|
|
|
xmlns:tns1="http://www.onvif.org/ver10/topics"
|
|
|
|
xmlns:tmd="http://www.onvif.org/ver10/deviceIO/wsdl"
|
|
|
|
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl"
|
|
|
|
xmlns:wsoap12="http://schemas.xmlsoap.org/wsdl/soap12"
|
|
|
|
xmlns:http="http://schemas.xmlsoap.org/wsdl/http"
|
|
|
|
xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery"
|
|
|
|
xmlns:wsadis="http://schemas.xmlsoap.org/ws/2004/08/addressing"
|
|
|
|
xmlns:wsnt="http://docs.oasis-open.org/wsn/b-2" xmlns:wsa="http://www.w3.org/2005/08/addressing"
|
|
|
|
xmlns:wstop="http://docs.oasis-open.org/wsn/t-1"
|
|
|
|
xmlns:wsrf-bf="http://docs.oasis-open.org/wsrf/bf-2"
|
|
|
|
xmlns:wsntw="http://docs.oasis-open.org/wsn/bw-2"
|
|
|
|
xmlns:wsrf-rw="http://docs.oasis-open.org/wsrf/rw-2"
|
|
|
|
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
|
|
|
|
xmlns:wsrf-r="http://docs.oasis-open.org/wsrf/r-2"
|
|
|
|
xmlns:trc="http://www.onvif.org/ver10/recording/wsdl"
|
|
|
|
xmlns:tse="http://www.onvif.org/ver10/search/wsdl"
|
|
|
|
xmlns:trp="http://www.onvif.org/ver10/replay/wsdl"
|
|
|
|
xmlns:tnshik="http://www.hikvision.com/2011/event/topics"
|
|
|
|
xmlns:hikwsd="http://www.onvifext.com/onvif/ext/ver10/wsdl"
|
|
|
|
xmlns:hikxsd="http://www.onvifext.com/onvif/ext/ver10/schema"
|
|
|
|
xmlns:tas="http://www.onvif.org/ver10/advancedsecurity/wsdl"
|
|
|
|
xmlns:tr2="http://www.onvif.org/ver20/media/wsdl"
|
|
|
|
xmlns:axt="http://www.onvif.org/ver20/analytics">
|
|
|
|
<env:Body>
|
|
|
|
<tse:GetRecordingSummaryResponse>
|
|
|
|
<tse:Summary>
|
|
|
|
<tt:DataFrom>2024-10-16T01:03:32Z</tt:DataFrom>
|
|
|
|
<tt:DataUntil>2024-10-30T09:41:47Z</tt:DataUntil>
|
|
|
|
<tt:NumberRecordings>1</tt:NumberRecordings>
|
|
|
|
</tse:Summary>
|
|
|
|
</tse:GetRecordingSummaryResponse>
|
|
|
|
</env:Body>
|
|
|
|
</env:Envelope>`
|
|
|
|
type Envelope struct {
|
|
|
|
Header struct{}
|
|
|
|
Body struct {
|
|
|
|
GetRecordingSummaryResponse GetRecordingSummaryResponse
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var reply Envelope
|
|
|
|
// var reply GetRecordingSummaryResponse
|
|
|
|
err := xml.Unmarshal([]byte(data), &reply)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
t.Log(reply)
|
|
|
|
}
|