TestHttpRpcServerWithPath
(t *testing.T)
| 21 | |
| 22 | // TestHttpRpcServerWithPath |
| 23 | func TestHttpRpcServerWithPath(t *testing.T) { |
| 24 | Convey("test http mode with service not found", t, func() { |
| 25 | |
| 26 | tcpServer := startRpcServerWithHttpMode(0, true) |
| 27 | defer stopRpcServer(tcpServer) |
| 28 | |
| 29 | Convey("test http mode with bad prefix path", func() { |
| 30 | sport := strconv.Itoa(PORT_1) |
| 31 | urlpath := "http://localhost:" + sport + "/badpath/EchoService/echo" |
| 32 | paramters := map[string]string{} |
| 33 | headers := map[string]string{} |
| 34 | |
| 35 | result := sendHttpRequest(urlpath, "POST", "{\"name\":\"matt\"}", paramters, headers) |
| 36 | So(result, ShouldNotBeNil) |
| 37 | data := &baidurpc.ResponseData{} |
| 38 | err := json.Unmarshal(result, data) |
| 39 | So(err, ShouldBeNil) |
| 40 | So(data.ErrNo, ShouldEqual, baidurpc.ST_SERVICE_NOTFOUND) |
| 41 | }) |
| 42 | |
| 43 | Convey("test http mode with bad service and method path", func() { |
| 44 | sport := strconv.Itoa(PORT_1) |
| 45 | urlpath := "http://localhost:" + sport + "/rpc/BadService/BadMethod" |
| 46 | paramters := map[string]string{} |
| 47 | headers := map[string]string{} |
| 48 | |
| 49 | result := sendHttpRequest(urlpath, "POST", "{\"name\":\"matt\"}", paramters, headers) |
| 50 | So(result, ShouldNotBeNil) |
| 51 | data := &baidurpc.ResponseData{} |
| 52 | err := json.Unmarshal(result, data) |
| 53 | So(err, ShouldBeNil) |
| 54 | So(data.ErrNo, ShouldEqual, baidurpc.ST_SERVICE_NOTFOUND) |
| 55 | }) |
| 56 | |
| 57 | }) |
| 58 | } |
| 59 | |
| 60 | // TestHttpRpcServer |
| 61 | func TestHttpRpcServer(t *testing.T) { |
nothing calls this directly
no test coverage detected