Snow-kal commented on code in PR #1144:
URL: https://github.com/apache/dubbo-go-samples/pull/1144#discussion_r3889587468
##########
generic/go-client/cmd/client.go:
##########
@@ -206,3 +197,111 @@ func runGenericTests(svc *genericService) bool {
return failed
}
+
+func runGenericModeChecks(cli *client.Client) bool {
+ failed := false
+ ctx := context.Background()
+
+ if _, err := cli.NewGenericService(
+ UserProvider,
+ client.WithURL(DirectServerURL),
+ client.WithVersion(ServiceVersion),
+ client.WithGroup(ServiceGroup),
+ client.WithGenericType("bad-type"),
+ client.WithSerialization(constant.Hessian2Serialization),
+ ); err == nil {
+ logger.Error("NewGenericService accepted an unknown generic
mode")
+ failed = true
+ } else {
+ logger.Infof("NewGenericService rejected unknown generic mode:
%v", err)
+ }
+
+ testCases := []struct {
+ name string
+ mode string
+ method string
+ types []string
+ args []hessian.Object
+ typed bool
+ expectedID string
+ }{
+ {
+ name: "true",
+ mode: constant.GenericSerializationDefault,
+ method: "GetUser1",
+ types: []string{"java.lang.String"},
+ args: []hessian.Object{"A003"},
+ typed: true,
+ expectedID: "A003",
+ },
+ {
+ name: "gson",
+ mode: constant.GenericSerializationGson,
+ method: "GetOneUser",
+ types: []string{},
+ args: []hessian.Object{},
+ },
+ {
+ name: "bean",
+ mode: constant.GenericSerializationBean,
+ method: "GetOneUser",
+ types: []string{},
+ args: []hessian.Object{},
+ typed: true,
+ expectedID: "1000",
+ },
+ }
+
+ for _, testCase := range testCases {
+ service, err := cli.NewGenericService(
+ UserProvider,
+ client.WithURL(DirectServerURL),
+ client.WithVersion(ServiceVersion),
+ client.WithGroup(ServiceGroup),
+ client.WithGenericType(testCase.mode),
+
client.WithSerialization(constant.Hessian2Serialization),
+ )
+ if err != nil {
+ logger.Errorf("create generic service (%s) failed: %v",
testCase.name, err)
+ failed = true
+ continue
+ }
+ if !testCase.typed {
+ result, invokeErr := service.Invoke(ctx,
testCase.method, testCase.types, testCase.args)
+ if invokeErr != nil {
+ logger.Errorf("%s generic result (%s) failed:
%v", testCase.method, testCase.name, invokeErr)
+ failed = true
+ continue
+ }
+ if result == nil {
Review Comment:
感谢建议 现已经更改
目前对于
Go provider 阶段:
- gson 结果必须为 string。
- 使用 json.Unmarshal 解析为 pkg.User。
- 严格校验 ID、Name、Age、Time。
Java provider 阶段:
- 显式识别 map[any]any/map[string]any fallback。
- 记录 Java provider 不支持 gson result encoding。
- 不再将 Map fallback 记录为 gson 成功。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]