Skip to content

Commit

Permalink
fix: Triple invocation with Json serialization (apache#2605)
Browse files Browse the repository at this point in the history
  • Loading branch information
DMwangnima authored Mar 5, 2024
1 parent ae70398 commit c865c83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions protocol/triple/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func newClientManager(url *common.URL) (*clientManager, error) {
case constant.ProtobufSerialization:
isIDL = true
case constant.JSONSerialization:
isIDL = true
cliOpts = append(cliOpts, tri.WithProtoJSON())
case constant.Hessian2Serialization:
cliOpts = append(cliOpts, tri.WithHessian2())
Expand Down
16 changes: 11 additions & 5 deletions protocol/triple/triple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func TestMain(m *testing.M) {
}

func TestInvoke(t *testing.T) {
tripleInvokerInit := func(location string, port string, interfaceName string, group string, version string, methods []string, info *client.ClientInfo) (protocol.Invoker, error) {
tripleInvokerInit := func(location string, port string, interfaceName string, group string, version string, methods []string, serialization string, info *client.ClientInfo) (protocol.Invoker, error) {
newURL := common.NewURLWithOptions(
common.WithInterface(interfaceName),
common.WithLocation(location),
Expand All @@ -199,6 +199,7 @@ func TestInvoke(t *testing.T) {
)
newURL.SetParam(constant.GroupKey, group)
newURL.SetParam(constant.VersionKey, version)
newURL.SetParam(constant.SerializationKey, serialization)
return NewTripleInvoker(newURL)
}
dubbo3InvokerInit := func(location string, port string, interfaceName string, group string, version string, svc common.RPCService) (protocol.Invoker, error) {
Expand Down Expand Up @@ -433,22 +434,27 @@ func TestInvoke(t *testing.T) {
}

t.Run("triple2triple", func(t *testing.T) {
invoker, err := tripleInvokerInit(localAddr, triplePort, customTripleInterfaceName, "", "", greettriple.GreetService_ClientInfo.MethodNames, &greettriple.GreetService_ClientInfo)
invoker, err := tripleInvokerInit(localAddr, triplePort, customTripleInterfaceName, "", "", greettriple.GreetService_ClientInfo.MethodNames, "", &greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker, "")
})
t.Run("triple2triple_JsonSerialization", func(t *testing.T) {
invoker, err := tripleInvokerInit(localAddr, triplePort, customTripleInterfaceName, "", "", greettriple.GreetService_ClientInfo.MethodNames, constant.JSONSerialization, &greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker, "")
})
t.Run("triple2triple_Group1Version1", func(t *testing.T) {
invoker, err := tripleInvokerInit(localAddr, triplePort, customTripleInterfaceName, group, version, greettriple.GreetService_ClientInfo.MethodNames, &greettriple.GreetService_ClientInfo)
invoker, err := tripleInvokerInit(localAddr, triplePort, customTripleInterfaceName, group, version, greettriple.GreetService_ClientInfo.MethodNames, "", &greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker, api.GroupVersionIdentifier)
})
t.Run("triple2dubbo3", func(t *testing.T) {
invoker, err := tripleInvokerInit(localAddr, dubbo3Port, customDubbo3InterfaceName, "", "", greettriple.GreetService_ClientInfo.MethodNames, &greettriple.GreetService_ClientInfo)
invoker, err := tripleInvokerInit(localAddr, dubbo3Port, customDubbo3InterfaceName, "", "", greettriple.GreetService_ClientInfo.MethodNames, "", &greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker, "")
})
t.Run("triple2dubbo3_Group1Version1", func(t *testing.T) {
invoker, err := tripleInvokerInit(localAddr, dubbo3Port, customDubbo3InterfaceName, group, version, greettriple.GreetService_ClientInfo.MethodNames, &greettriple.GreetService_ClientInfo)
invoker, err := tripleInvokerInit(localAddr, dubbo3Port, customDubbo3InterfaceName, group, version, greettriple.GreetService_ClientInfo.MethodNames, "", &greettriple.GreetService_ClientInfo)
assert.Nil(t, err)
invokeTripleCodeFunc(t, invoker, dubbo3_api.GroupVersionIdentifier)
})
Expand Down

0 comments on commit c865c83

Please sign in to comment.