示例#1
0
func TestSM_Query_ServiceUnavailable(t *testing.T) {
	tx := smpp.Transceiver{Addr: ":0"}
	defer tx.Close()
	<-tx.Bind()
	sm := NewSM(&tx, rpc.NewServer())
	req := &QueryMessage{
		MessageID: "13",
	}
	var resp QueryMessageResp
	err := sm.Query(req, &resp)
	if err != nil {
		if !strings.HasPrefix(err.Error(), "503 Service Unavailable") {
			t.Fatal(err)
		}
		return
	}
	t.Fatal("query with no server is not supposed to work")
}
示例#2
0
func TestSM_Submit_ServiceUnavailable(t *testing.T) {
	tx := smpp.Transceiver{Addr: ":0"}
	defer tx.Close()
	<-tx.Bind()
	sm := NewSM(&tx, rpc.NewServer())
	req := &ShortMessage{
		Dst:  "root",
		Text: "gotcha",
	}
	var resp ShortMessageResp
	err := sm.Submit(req, &resp)
	if err != nil {
		if !strings.HasPrefix(err.Error(), "503 Service Unavailable") {
			t.Fatal(err)
		}
		return
	}
	t.Fatal("submit with no server is not supposed to work")
}