Skip to content
Snippets Groups Projects
Commit cd8a755b authored by Patrick's avatar Patrick
Browse files

add test

parent 0f7eba20
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,8 @@ import (
"context"
"github.com/apache/dubbo-go/protocol/rest/client"
"github.com/apache/dubbo-go/protocol/rest/client/client_impl"
"github.com/apache/dubbo-go/protocol/rest/server/server_impl"
"github.com/emicklei/go-restful/v3"
"testing"
"time"
)
......@@ -42,6 +44,18 @@ func TestRestInvoker_Invoke(t *testing.T) {
// Refer
proto := GetRestProtocol()
defer proto.Destroy()
var filterNum int
server_impl.AddGoRestfulServerFilter(func(request *restful.Request, response *restful.Response, chain *restful.FilterChain) {
println(request.SelectedRoutePath())
filterNum = filterNum + 1
chain.ProcessFilter(request, response)
})
server_impl.AddGoRestfulServerFilter(func(request *restful.Request, response *restful.Response, chain *restful.FilterChain) {
println("filter2")
filterNum = filterNum + 1
chain.ProcessFilter(request, response)
})
url, err := common.NewURL("rest://127.0.0.1:8877/com.ikurento.user.UserProvider?anyhost=true&" +
"application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" +
"environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" +
......@@ -192,6 +206,7 @@ func TestRestInvoker_Invoke(t *testing.T) {
res = invoker.Invoke(context.Background(), inv)
assert.Error(t, res.Error(), "test error")
assert.Equal(t, filterNum, 12)
err = common.ServiceMap.UnRegister(url.Protocol, "com.ikurento.user.UserProvider")
assert.NoError(t, err)
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment