Skip to content
Snippets Groups Projects
Commit c5934640 authored by fangyincheng's avatar fangyincheng
Browse files

fix ut

parent c7fd69aa
No related branches found
No related tags found
No related merge requests found
......@@ -96,12 +96,12 @@ func TestServiceMapRegister(t *testing.T) {
// repeat
_, err = ServiceMap.Register(testInterfaceName, "testporotocol", "", "v1", s)
assert.EqualError(t, err, "service already defined: com.test.Path")
assert.EqualError(t, err, "service already defined: testService:v1")
// no method
s1 := &TestService1{}
_, err = ServiceMap.Register(testInterfaceName, "testporotocol", "", "v2", s1)
assert.EqualError(t, err, "type com.test.Path1 has no exported methods of suitable type")
assert.EqualError(t, err, "type testService:v2 has no exported methods of suitable type")
ServiceMap = &serviceMap{
serviceMap: make(map[string]map[string]*Service),
......
......@@ -96,7 +96,7 @@ func TestGenericServiceFilterInvoke(t *testing.T) {
hessian.Object("222")},
}
s := &TestService{}
_, _ = common.ServiceMap.Register("TestService", "testprotocol", "", "", s)
_, _ = common.ServiceMap.Register("com.test.Path", "testprotocol", "", "", s)
rpcInvocation := invocation.NewRPCInvocation(methodName, aurguments, nil)
filter := GetGenericServiceFilter()
url, _ := common.NewURL("testprotocol://127.0.0.1:20000/com.test.Path")
......
......@@ -69,7 +69,7 @@ func TestConfigurableExporter(t *testing.T) {
assert.Equal(t, false, exported.IsExported())
assert.NoError(t, exported.Export(registryURL))
assert.Equal(t, true, exported.IsExported())
assert.Regexp(t, "dubbo://:20003/MetadataService*", exported.GetExportedURLs()[0].String())
assert.Regexp(t, "dubbo://:20003/org.apache.dubbo.metadata.MetadataService*", exported.GetExportedURLs()[0].String())
exported.Unexport()
assert.Equal(t, false, exported.IsExported())
})
......
......@@ -97,7 +97,7 @@ func InitTest(t *testing.T) (protocol.Protocol, *common.URL) {
hessian.RegisterPOJO(&User{})
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "dubbo", "", "0.0.1", &UserProvider{})
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "dubbo", "", "", &UserProvider{})
assert.NoError(t, err)
assert.Equal(t, "GetBigPkg,GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4,GetUser5,GetUser6", methods)
......
......@@ -49,7 +49,7 @@ type (
)
const (
mockJsonCommonUrl = "jsonrpc://127.0.0.1:20001/UserProvider?anyhost=true&" +
mockJsonCommonUrl = "jsonrpc://127.0.0.1:20001/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&" +
......@@ -58,7 +58,7 @@ const (
func TestHTTPClientCall(t *testing.T) {
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "0.0.1", &UserProvider{})
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "", &UserProvider{})
assert.NoError(t, err)
assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods)
......
......@@ -36,13 +36,13 @@ import (
func TestJsonrpcInvokerInvoke(t *testing.T) {
methods, err := common.ServiceMap.Register("UserProvider", "jsonrpc", "", "0.0.1", &UserProvider{})
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "", &UserProvider{})
assert.NoError(t, err)
assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods)
// Export
proto := GetProtocol()
url, err := common.NewURL("jsonrpc://127.0.0.1:20001/UserProvider?anyhost=true&" +
url, err := common.NewURL("jsonrpc://127.0.0.1:20001/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&" +
......
......@@ -120,8 +120,6 @@ func TestRestProtocolExport(t *testing.T) {
proto.Destroy()
_, ok = proto.(*RestProtocol).serverMap[url.Location]
assert.False(t, ok)
err = common.ServiceMap.UnRegister(url.Service(), url.Protocol, url.ServiceKey())
assert.NoError(t, err)
}
type UserProvider struct {
......
......@@ -211,7 +211,9 @@ func testGetUser3(t *testing.T, c *Client) {
request := remoting.NewRequest("2.0.2")
invocation := createInvocation("GetUser3", nil, nil, []interface{}{},
[]reflect.Value{})
attachment := map[string]string{INTERFACE_KEY: "com.ikurento.user.UserProvider"}
attachment := map[string]string{
INTERFACE_KEY: "com.ikurento.user.UserProvider",
}
setAttachment(invocation, attachment)
request.Data = invocation
request.Event = false
......@@ -341,7 +343,7 @@ func InitTest(t *testing.T) (*Server, *common.URL) {
hessian.RegisterPOJO(&User{})
remoting.RegistryCodec("dubbo", &DubboTestCodec{})
methods, err := common.ServiceMap.Register("", "dubbo", "", "0.0.1", &UserProvider{})
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "dubbo", "", "", &UserProvider{})
assert.NoError(t, err)
assert.Equal(t, "GetBigPkg,GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4,GetUser5,GetUser6", methods)
......@@ -387,7 +389,7 @@ func InitTest(t *testing.T) (*Server, *common.URL) {
}})
assert.NoError(t, srvConf.CheckValidity())
url, err := common.NewURL("dubbo://127.0.0.1:20060/UserProvider?anyhost=true&" +
url, err := common.NewURL("dubbo://127.0.0.1:20060/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=127.0.0.1&methods=GetUser%2C&" +
"module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" +
......
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