This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new a929410ef refactor: remove config package dependency from protocol
tests (#3194)
a929410ef is described below
commit a929410ef42b388b57f8013b6126169c336ae107
Author: CAICAII <[email protected]>
AuthorDate: Fri Feb 6 18:04:42 2026 +0800
refactor: remove config package dependency from protocol tests (#3194)
- Delete protocol/dubbo3/common_test.go (per existing TODO comment)
- Delete protocol/rest/rest_invoker_test.go (all code was commented out)
- Delete protocol/rest/rest_protocol_test.go (all code was commented out)
- Refactor protocol/grpc/grpc_protocol_test.go: remove
TestGrpcProtocolExport
which depends on config.SetProviderService() and config.SetRootConfig()
- Refactor protocol/jsonrpc/jsonrpc_protocol_test.go: replace
config.SetConsumerConfig() with URL attribute injection pattern
Relates to #2741
---
protocol/dubbo3/common_test.go | 47 -------
protocol/dubbo3/dubbo3_protocol_test.go | 61 ---------
protocol/grpc/grpc_protocol_test.go | 68 ----------
protocol/jsonrpc/jsonrpc_protocol_test.go | 11 +-
protocol/rest/rest_invoker_test.go | 217 ------------------------------
protocol/rest/rest_protocol_test.go | 176 ------------------------
6 files changed, 6 insertions(+), 574 deletions(-)
diff --git a/protocol/dubbo3/common_test.go b/protocol/dubbo3/common_test.go
deleted file mode 100644
index 3a16f69c3..000000000
--- a/protocol/dubbo3/common_test.go
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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 dubbo3
-
-import (
- "context"
- "fmt"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/config"
- "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/internal"
-)
-
-// TODO: After the config is removed, remove the test
-// userd dubbo3 biz service
-func addService() {
- config.SetProviderService(newGreeterProvider())
-}
-
-type greeterProvider struct {
- internal.UnimplementedGreeterServer
-}
-
-func newGreeterProvider() *greeterProvider {
- return &greeterProvider{}
-}
-
-func (g *greeterProvider) SayHello(ctx context.Context, req
*internal.HelloRequest) (reply *internal.HelloReply, err error) {
- fmt.Printf("req: %v", req)
- return &internal.HelloReply{Message: "this is message from reply"}, nil
-}
diff --git a/protocol/dubbo3/dubbo3_protocol_test.go
b/protocol/dubbo3/dubbo3_protocol_test.go
index c9fc4b5d6..691799465 100644
--- a/protocol/dubbo3/dubbo3_protocol_test.go
+++ b/protocol/dubbo3/dubbo3_protocol_test.go
@@ -21,7 +21,6 @@ import (
"context"
"reflect"
"testing"
- "time"
)
import (
@@ -31,66 +30,6 @@ import (
"github.com/stretchr/testify/require"
)
-import (
- "dubbo.apache.org/dubbo-go/v3/common"
- "dubbo.apache.org/dubbo-go/v3/protocol/base"
-)
-
-const (
- mockDubbo3CommonUrl =
"tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterProvider"
+
-
"&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=org.apache.dubbo.DubboGreeterImpl"
+
-
"&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy="
+
-
"&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries="
+
-
"&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider×tamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!"
-)
-
-func TestDubboProtocolExport(t *testing.T) {
- // Export
- addService()
-
- proto := GetProtocol()
- url, err := common.NewURL(mockDubbo3CommonUrl)
- require.NoError(t, err)
- exporter := proto.Export(base.NewBaseInvoker(url))
- time.Sleep(time.Second)
-
- // make sure url
- eq := exporter.GetInvoker().GetURL().URLEqual(url)
- assert.True(t, eq)
-
- // make sure exporterMap after 'UnExport'
- _, ok := proto.(*DubboProtocol).ExporterMap().Load(url.ServiceKey())
- assert.True(t, ok)
- exporter.UnExport()
- _, ok = proto.(*DubboProtocol).ExporterMap().Load(url.ServiceKey())
- assert.False(t, ok)
-
- // make sure serverMap after 'Destroy'
- _, ok = proto.(*DubboProtocol).serverMap[url.Location]
- assert.True(t, ok)
- proto.Destroy()
- _, ok = proto.(*DubboProtocol).serverMap[url.Location]
- assert.False(t, ok)
-}
-
-func TestDubboProtocolRefer(t *testing.T) {
- proto := GetProtocol()
- url, err := common.NewURL(mockDubbo3CommonUrl)
- require.NoError(t, err)
- invoker := proto.Refer(url)
-
- // make sure url
- eq := invoker.GetURL().URLEqual(url)
- assert.True(t, eq)
-
- // make sure invokers after 'Destroy'
- invokersLen := len(proto.(*DubboProtocol).Invokers())
- assert.Equal(t, 1, invokersLen)
- proto.Destroy()
- invokersLen = len(proto.(*DubboProtocol).Invokers())
- assert.Equal(t, 0, invokersLen)
-}
-
type MockUser struct {
Name string
}
diff --git a/protocol/grpc/grpc_protocol_test.go
b/protocol/grpc/grpc_protocol_test.go
index b95a76bfd..6a2e09002 100644
--- a/protocol/grpc/grpc_protocol_test.go
+++ b/protocol/grpc/grpc_protocol_test.go
@@ -19,7 +19,6 @@ package grpc
import (
"testing"
- "time"
)
import (
@@ -29,76 +28,9 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/common"
- "dubbo.apache.org/dubbo-go/v3/config"
- "dubbo.apache.org/dubbo-go/v3/protocol/base"
"dubbo.apache.org/dubbo-go/v3/protocol/grpc/internal/helloworld"
)
-func doInitProvider() {
- rootConfig := config.RootConfig{
- Application: &config.ApplicationConfig{
- Organization: "dubbo_org",
- Name: "BDTService",
- Module: "module",
- Version: "0.0.1",
- Owner: "dubbo",
- Environment: "test",
- },
- Provider: &config.ProviderConfig{
- Services: map[string]*config.ServiceConfig{
- "GrpcGreeterImpl": {
- Interface:
"io.grpc.examples.helloworld.GreeterGrpc$IGreeter",
- ProtocolIDs: []string{"grpc"},
- RegistryIDs:
[]string{"shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg"},
- Cluster: "failover",
- Loadbalance: "random",
- Retries: "3",
- Methods: []*config.MethodConfig{
- {
- Name: "SayHello",
- Retries: "2",
- LoadBalance: "random",
- Weight: 200,
- },
- },
- },
- },
- },
- }
- config.SetRootConfig(rootConfig)
-}
-
-func TestGrpcProtocolExport(t *testing.T) {
- // Export
- config.SetProviderService(helloworld.NewService())
- doInitProvider()
-
- url, err := common.NewURL(helloworldURL)
- require.NoError(t, err)
-
- proto := GetProtocol()
- exporter := proto.Export(base.NewBaseInvoker(url))
- time.Sleep(time.Second)
-
- // make sure url
- eq := exporter.GetInvoker().GetURL().URLEqual(url)
- assert.True(t, eq)
-
- // make sure exporterMap after 'UnExport'
- _, ok := proto.(*GrpcProtocol).ExporterMap().Load(url.ServiceKey())
- assert.True(t, ok)
- exporter.UnExport()
- _, ok = proto.(*GrpcProtocol).ExporterMap().Load(url.ServiceKey())
- assert.False(t, ok)
-
- // make sure serverMap after 'Destroy'
- _, ok = proto.(*GrpcProtocol).serverMap[url.Location]
- assert.True(t, ok)
- proto.Destroy()
- _, ok = proto.(*GrpcProtocol).serverMap[url.Location]
- assert.False(t, ok)
-}
-
func TestGrpcProtocolRefer(t *testing.T) {
server, err := helloworld.NewServer("127.0.0.1:30000")
require.NoError(t, err)
diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go
b/protocol/jsonrpc/jsonrpc_protocol_test.go
index dfdcfb70b..7f10830d5 100644
--- a/protocol/jsonrpc/jsonrpc_protocol_test.go
+++ b/protocol/jsonrpc/jsonrpc_protocol_test.go
@@ -30,7 +30,8 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/common"
- "dubbo.apache.org/dubbo-go/v3/config"
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ "dubbo.apache.org/dubbo-go/v3/global"
"dubbo.apache.org/dubbo-go/v3/protocol/base"
)
@@ -65,7 +66,6 @@ func TestJsonrpcProtocolExport(t *testing.T) {
assert.False(t, ok)
}
-// TODO: After discarding the config package, delete the test
func TestJsonrpcProtocolRefer(t *testing.T) {
// Refer
proto := GetProtocol()
@@ -75,11 +75,12 @@ func TestJsonrpcProtocolRefer(t *testing.T) {
"module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&"
+
"side=provider&timeout=3000×tamp=1556509797245")
require.NoError(t, err)
- // TODO: Temporary compatibility with old APIs, can be removed later
- con := config.ConsumerConfig{
+
+ // Pass ConsumerConfig via URL attribute instead of using
config.SetConsumerConfig()
+ consumerConf := &global.ConsumerConfig{
RequestTimeout: "5s",
}
- config.SetConsumerConfig(con)
+ url.SetAttribute(constant.ConsumerConfigKey, consumerConf)
invoker := proto.Refer(url)
diff --git a/protocol/rest/rest_invoker_test.go
b/protocol/rest/rest_invoker_test.go
deleted file mode 100644
index 35e9526c6..000000000
--- a/protocol/rest/rest_invoker_test.go
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * 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 rest
-
-//
-//import (
-// "context"
-// "testing"
-// "time"
-//)
-//
-//import (
-// "github.com/emicklei/go-restful/v3"
-//
-// "github.com/stretchr/testify/assert"
-//)
-//
-//import (
-// "dubbo.apache.org/dubbo-go/v3/common"
-// "dubbo.apache.org/dubbo-go/v3/common/extension"
-// "dubbo.apache.org/dubbo-go/v3/config"
-// "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
-// "dubbo.apache.org/dubbo-go/v3/protocol/rest/client"
-// "dubbo.apache.org/dubbo-go/v3/protocol/rest/client/client_impl"
-// rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config"
-// "dubbo.apache.org/dubbo-go/v3/protocol/rest/server/server_impl"
-//)
-//
-//const (
-// mockRestCommonUrl =
"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&"
+
-//
"module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&"
+
-//
"side=provider&timeout=3000×tamp=1556509797245&bean.name=com.ikurento.user.UserProvider"
-//)
-//
-//func TestRestInvokerInvoke(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(mockRestCommonUrl)
-// assert.NoError(t, err)
-// _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "",
"", &UserProvider{})
-// assert.NoError(t, err)
-// con := config.ProviderConfig{}
-// config.SetProviderConfig(con)
-// configMap := make(map[string]*rest_config.RestServiceConfig)
-// methodConfigMap := make(map[string]*rest_config.RestMethodConfig)
-// queryParamsMap := make(map[int]string)
-// queryParamsMap[1] = "age"
-// queryParamsMap[2] = "name"
-// pathParamsMap := make(map[int]string)
-// pathParamsMap[0] = "userid"
-// headersMap := make(map[int]string)
-// headersMap[3] = "Content-Type"
-// methodConfigMap["GetUserOne"] = &rest_config.RestMethodConfig{
-// InterfaceName: "",
-// MethodName: "GetUserOne",
-// Path: "/GetUserOne",
-// Produces: "application/json",
-// Consumes: "application/json",
-// MethodType: "POST",
-// PathParams: "",
-// PathParamsMap: nil,
-// QueryParams: "",
-// QueryParamsMap: nil,
-// Body: 0,
-// }
-// methodConfigMap["GetUserTwo"] = &rest_config.RestMethodConfig{
-// InterfaceName: "",
-// MethodName: "GetUserTwo",
-// Path: "/GetUserTwo",
-// Produces: "application/json",
-// Consumes: "application/json",
-// MethodType: "POST",
-// PathParams: "",
-// PathParamsMap: nil,
-// QueryParams: "",
-// QueryParamsMap: nil,
-// Body: 0,
-// }
-// methodConfigMap["GetUserThree"] = &rest_config.RestMethodConfig{
-// InterfaceName: "",
-// MethodName: "GetUserThree",
-// Path: "/GetUserThree",
-// Produces: "application/json",
-// Consumes: "application/json",
-// MethodType: "POST",
-// PathParams: "",
-// PathParamsMap: nil,
-// QueryParams: "",
-// QueryParamsMap: nil,
-// Body: 0,
-// }
-// methodConfigMap["GetUserFour"] = &rest_config.RestMethodConfig{
-// InterfaceName: "",
-// MethodName: "GetUserFour",
-// Path: "/GetUserFour",
-// Produces: "application/json",
-// Consumes: "application/json",
-// MethodType: "POST",
-// PathParams: "",
-// PathParamsMap: nil,
-// QueryParams: "",
-// QueryParamsMap: nil,
-// Body: 0,
-// }
-// methodConfigMap["GetUserFive"] = &rest_config.RestMethodConfig{
-// InterfaceName: "",
-// MethodName: "GetUserFive",
-// Path: "/GetUserFive",
-// Produces: "*/*",
-// Consumes: "*/*",
-// MethodType: "GET",
-// }
-// methodConfigMap["GetUser"] = &rest_config.RestMethodConfig{
-// InterfaceName: "",
-// MethodName: "GetUser",
-// Path: "/GetUser/{userid}",
-// Produces: "application/json",
-// Consumes: "application/json",
-// MethodType: "GET",
-// PathParams: "",
-// PathParamsMap: pathParamsMap,
-// QueryParams: "",
-// QueryParamsMap: queryParamsMap,
-// Body: -1,
-// HeadersMap: headersMap,
-// }
-//
-// configMap["com.ikurento.user.UserProvider"] =
&rest_config.RestServiceConfig{
-// Server: "go-restful",
-// RestMethodConfigsMap: methodConfigMap,
-// }
-// rest_config.SetRestProviderServiceConfigMap(configMap)
-// proxyFactory := extension.GetProxyFactory("default")
-// proto.Export(proxyFactory.GetInvoker(url))
-// time.Sleep(5 * time.Second)
-// configMap = make(map[string]*rest_config.RestServiceConfig)
-// configMap["com.ikurento.user.UserProvider"] =
&rest_config.RestServiceConfig{
-// RestMethodConfigsMap: methodConfigMap,
-// }
-// restClient :=
client_impl.NewRestyClient(&client.RestOptions{ConnectTimeout: 3 * time.Second,
RequestTimeout: 3 * time.Second})
-// invoker := NewRestInvoker(url, &restClient, methodConfigMap)
-// user := &User{}
-// inv :=
invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUser"),
-// invocation.WithArguments([]any{1, int32(23), "username",
"application/json"}), invocation.WithReply(user))
-// res := invoker.Invoke(context.Background(), inv)
-// assert.NoError(t, res.Error())
-// assert.Equal(t, User{ID: 1, Age: int32(23), Name: "username"},
*res.Result().(*User))
-// now := time.Now()
-// inv =
invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserOne"),
-// invocation.WithArguments([]any{&User{1, &now, int32(23),
"username"}}), invocation.WithReply(user))
-// res = invoker.Invoke(context.Background(), inv)
-// assert.NoError(t, res.Error())
-// assert.NotNil(t, res.Result())
-// assert.Equal(t, 1, res.Result().(*User).ID)
-// assert.Equal(t, now.Unix(), res.Result().(*User).Time.Unix())
-// assert.Equal(t, int32(23), res.Result().(*User).Age)
-// assert.Equal(t, "username", res.Result().(*User).Name)
-// // test 1
-// inv =
invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserTwo"),
-// invocation.WithArguments([]any{&User{1, &now, int32(23),
"username"}}), invocation.WithReply(user))
-// res = invoker.Invoke(context.Background(), inv)
-// assert.NoError(t, res.Error())
-// assert.NotNil(t, res.Result())
-// assert.Equal(t, "username", res.Result().(*User).Name)
-// // test 2
-// inv =
invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserThree"),
-// invocation.WithArguments([]any{&User{1, &now, int32(23),
"username"}}), invocation.WithReply(user))
-// res = invoker.Invoke(context.Background(), inv)
-// assert.NoError(t, res.Error())
-// assert.NotNil(t, res.Result())
-// assert.Equal(t, "username", res.Result().(*User).Name)
-// // test 3
-// inv =
invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserFour"),
-// invocation.WithArguments([]any{[]User{{1, nil, int32(23),
"username"}}}), invocation.WithReply(user))
-// res = invoker.Invoke(context.Background(), inv)
-// assert.NoError(t, res.Error())
-// assert.NotNil(t, res.Result())
-// assert.Equal(t, "username", res.Result().(*User).Name)
-// // test 4
-// inv =
invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserFive"),
invocation.WithReply(user))
-// res = invoker.Invoke(context.Background(), inv)
-// assert.Error(t, res.Error(), "test error")
-//
-// assert.Equal(t, filterNum, 12)
-// err = common.ServiceMap.UnRegister(url.Service(), url.Protocol,
url.ServiceKey())
-// assert.NoError(t, err)
-//}
diff --git a/protocol/rest/rest_protocol_test.go
b/protocol/rest/rest_protocol_test.go
deleted file mode 100644
index 39c53d38b..000000000
--- a/protocol/rest/rest_protocol_test.go
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 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 rest
-
-//
-//import (
-// "context"
-// "errors"
-// "fmt"
-// "strings"
-// "testing"
-// "time"
-//)
-//
-//import (
-// "github.com/stretchr/testify/assert"
-//)
-//
-//import (
-// "dubbo.apache.org/dubbo-go/v3/common"
-// "dubbo.apache.org/dubbo-go/v3/common/extension"
-// _ "dubbo.apache.org/dubbo-go/v3/proxy/proxy_factory"
-// "dubbo.apache.org/dubbo-go/v3/config"
-// rest_config "dubbo.apache.org/dubbo-go/v3/protocol/rest/config"
-//)
-//
-//func TestRestProtocolRefer(t *testing.T) {
-// // Refer
-// proto := GetRestProtocol()
-// url, err := common.NewURL(mockRestCommonUrl)
-// assert.NoError(t, err)
-// con := config.ConsumerConfig{
-// ConnectTimeout: "5s",
-// RequestTimeout: "5s",
-// }
-// config.SetConsumerConfig(con)
-// configMap := make(map[string]*rest_config.RestServiceConfig)
-// configMap["com.ikurento.user.UserProvider"] =
&rest_config.RestServiceConfig{
-// Client: "resty",
-// }
-// rest_config.SetRestConsumerServiceConfigMap(configMap)
-// invoker := proto.Refer(url)
-//
-// // make sure url
-// eq := invoker.GetURL().URLEqual(url)
-// assert.True(t, eq)
-//
-// // make sure invokers after 'Destroy'
-// invokersLen := len(proto.(*RestProtocol).Invokers())
-// assert.Equal(t, 1, invokersLen)
-// proto.Destroy()
-// invokersLen = len(proto.(*RestProtocol).Invokers())
-// assert.Equal(t, 0, invokersLen)
-//}
-//
-//func TestRestProtocolExport(t *testing.T) {
-// // Export
-// proto := GetRestProtocol()
-// url, err := common.NewURL(mockRestCommonUrl)
-// assert.NoError(t, err)
-// _, err = common.ServiceMap.Register(url.Service(), url.Protocol, "",
"", &UserProvider{})
-// assert.NoError(t, err)
-// con := config.ProviderConfig{}
-// config.SetProviderConfig(con)
-// configMap := make(map[string]*rest_config.RestServiceConfig)
-// methodConfigMap := make(map[string]*rest_config.RestMethodConfig)
-// queryParamsMap := make(map[int]string)
-// queryParamsMap[1] = "age"
-// queryParamsMap[2] = "name"
-// pathParamsMap := make(map[int]string)
-// pathParamsMap[0] = "userid"
-// methodConfigMap["GetUser"] = &rest_config.RestMethodConfig{
-// InterfaceName: "",
-// MethodName: "GetUser",
-// Path: "/GetUser/{userid}",
-// Produces: "application/json",
-// Consumes: "application/json",
-// MethodType: "GET",
-// PathParams: "",
-// PathParamsMap: pathParamsMap,
-// QueryParams: "",
-// QueryParamsMap: queryParamsMap,
-// Body: -1,
-// }
-// configMap["com.ikurento.user.UserProvider"] =
&rest_config.RestServiceConfig{
-// Server: "go-restful",
-// RestMethodConfigsMap: methodConfigMap,
-// }
-// rest_config.SetRestProviderServiceConfigMap(configMap)
-// proxyFactory := extension.GetProxyFactory("default")
-// exporter := proto.Export(proxyFactory.GetInvoker(url))
-// // make sure url
-// eq := exporter.GetInvoker().GetURL().URLEqual(url)
-// assert.True(t, eq)
-// // make sure exporterMap after 'UnExport'
-// fmt.Println(url.Path)
-// _, ok :=
proto.(*RestProtocol).ExporterMap().Load(strings.TrimPrefix(url.Path, "/"))
-// assert.True(t, ok)
-// exporter.UnExport()
-// _, ok =
proto.(*RestProtocol).ExporterMap().Load(strings.TrimPrefix(url.Path, "/"))
-// assert.False(t, ok)
-//
-// // make sure serverMap after 'Destroy'
-// _, ok = proto.(*RestProtocol).serverMap[url.Location]
-// assert.True(t, ok)
-// proto.Destroy()
-// _, ok = proto.(*RestProtocol).serverMap[url.Location]
-// assert.False(t, ok)
-//}
-//
-//type UserProvider struct{}
-//
-//func (p *UserProvider) Reference() string {
-// return "com.ikurento.user.UserProvider"
-//}
-//
-//func (p *UserProvider) GetUser(ctx context.Context, id int, age int32, name
string, contentType string) (*User, error) {
-// return &User{
-// ID: id,
-// Time: nil,
-// Age: age,
-// Name: name,
-// }, nil
-//}
-//
-//func (p *UserProvider) GetUserOne(ctx context.Context, user *User) (*User,
error) {
-// return user, nil
-//}
-//
-//func (p *UserProvider) GetUserTwo(ctx context.Context, req []any, rsp *User)
error {
-// m := req[0].(map[string]any)
-// rsp.Name = m["Name"].(string)
-// return nil
-//}
-//
-//func (p *UserProvider) GetUserThree(ctx context.Context, user any) (*User,
error) {
-// m := user.(map[string]any)
-//
-// u := &User{}
-// u.Name = m["Name"].(string)
-// return u, nil
-//}
-//
-//func (p *UserProvider) GetUserFour(ctx context.Context, user []any, id
string) (*User, error) {
-// m := user[0].(map[string]any)
-//
-// u := &User{}
-// u.Name = m["Name"].(string)
-// return u, nil
-//}
-//
-//func (p *UserProvider) GetUserFive(ctx context.Context, user []any) (*User,
error) {
-// return nil, errors.New("test error")
-//}
-//
-//type User struct {
-// ID int
-// Time *time.Time
-// Age int32
-// Name string
-//}