You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/07/05 07:34:32 UTC

[GitHub] [dubbo-go-samples] yamicro commented on a change in pull request #159: 1.5 The integration of genearl json and rest

yamicro commented on a change in pull request #159:
URL: https://github.com/apache/dubbo-go-samples/pull/159#discussion_r663703262



##########
File path: general/jsonrpc/go-server/tests/integration/main_test.go
##########
@@ -0,0 +1,132 @@
+// +build integration
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package integration
+
+import (
+	"context"
+	"fmt"
+	"os"
+	"testing"
+	"time"
+)
+
+import (
+	hessian "github.com/apache/dubbo-go-hessian2"
+	_ "github.com/apache/dubbo-go/cluster/cluster_impl"
+	_ "github.com/apache/dubbo-go/cluster/loadbalance"
+	_ "github.com/apache/dubbo-go/common/proxy/proxy_factory"
+	"github.com/apache/dubbo-go/config"
+	_ "github.com/apache/dubbo-go/filter/filter_impl"
+	_ "github.com/apache/dubbo-go/protocol/jsonrpc"
+	_ "github.com/apache/dubbo-go/registry/protocol"
+	_ "github.com/apache/dubbo-go/registry/zookeeper"
+)
+
+var (
+	userProvider = new(UserProvider)
+	userProvider1 = new(UserProvider1)
+	userProvider2 = new(UserProvider2)
+)
+
+
+func TestMain(m *testing.M) {
+
+	config.SetConsumerService(userProvider)
+	config.SetConsumerService(userProvider1)
+	config.SetConsumerService(userProvider2)
+	hessian.RegisterPOJO(&UserProvider{})
+	hessian.RegisterPOJO(&UserProvider1{})
+	hessian.RegisterPOJO(&UserProvider2{})
+
+	config.Load()
+	time.Sleep(3 * time.Second)
+
+	os.Exit(m.Run())
+}
+
+
+type JsonRPCUser struct {
+	ID   string `json:"id"`
+	Name string `json:"name"`
+	Age  int64  `json:"age"`
+	Time int64  `json:"time"`
+	Sex  string `json:"sex"`
+}
+
+func (u JsonRPCUser) String() string {
+	return fmt.Sprintf(
+		"User{ID:%s, Name:%s, Age:%d, Time:%s, Sex:%s}",
+		u.ID, u.Name, u.Age, time.Unix(u.Time, 0).Format("2006-01-02 15:04:05.99999"), u.Sex,
+	)
+}
+
+type UserProvider struct {
+	GetUsers func(req []interface{}) ([]JsonRPCUser, error)
+	GetUser  func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error
+	GetUser0 func(id string, name string) (JsonRPCUser, error)
+	GetUser1 func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error
+	GetUser2 func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error `dubbo:"getUser"`
+	GetUser3 func() error
+	Echo     func(ctx context.Context, req interface{}) (interface{}, error) // Echo represent EchoFilter will be used
+}
+
+func (u *UserProvider) Reference() string {
+	return "UserProvider"
+}
+
+type UserProvider1 struct {
+	GetUsers func(req []interface{}) ([]JsonRPCUser, error)
+	GetUser  func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error
+	GetUser0 func(id string, name string) (JsonRPCUser, error)
+	GetUser1 func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error
+	GetUser2 func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error `dubbo:"getUser"`
+	GetUser3 func() error
+	Echo     func(ctx context.Context, req interface{}) (interface{}, error) // Echo represent EchoFilter will be used
+}
+
+func (u *UserProvider1) Reference() string {
+	return "UserProvider1"
+}
+
+type UserProvider2 struct {
+	GetUsers func(req []interface{}) ([]JsonRPCUser, error)
+	GetUser  func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error
+	GetUser0 func(id string, name string) (JsonRPCUser, error)
+	GetUser1 func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error
+	GetUser2 func(ctx context.Context, req []interface{}, rsp *JsonRPCUser) error `dubbo:"getUser"`
+	GetUser3 func() error
+	Echo     func(ctx context.Context, req interface{}) (interface{}, error) // Echo represent EchoFilter will be used
+}
+
+func (u *UserProvider2) Reference() string {
+	return "UserProvider2"
+}
+
+func (UserProvider) JavaClassName() string {
+	return "com.ikurento.user.UserProvider"
+}
+
+func (UserProvider1) JavaClassName() string {
+	return "com.ikurento.user.UserProvider"

Review comment:
       I imitate the previous code.In the previous code three UserProvider use the same interface name in configuration file.So I user the com.ikurento.user.UserProvider.




-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org