Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package config
import (
"github.com/dubbo/go-for-apache-dubbo/common/extension"
"github.com/stretchr/testify/assert"
"testing"
)
func doinit() {
providerConfig = &ProviderConfig{
ApplicationConfig: ApplicationConfig{
Organization: "dubbo_org",
Name: "dubbo",
Module: "module",
Version: "2.6.0",
Owner: "dubbo",
Environment: "test"},
Registries: []RegistryConfig{
{
Id: "shanghai_reg1",
Type: "mock",
TimeoutStr: "2s",
Group: "shanghai_idc",
Address: "127.0.0.1:2181",
Username: "user1",
Password: "pwd1",
},
{
Id: "shanghai_reg2",
Type: "mock",
TimeoutStr: "2s",
Group: "shanghai_idc",
Address: "127.0.0.2:2181",
Username: "user1",
Password: "pwd1",
},
{
Id: "hangzhou_reg1",
Type: "mock",
TimeoutStr: "2s",
Group: "hangzhou_idc",
Address: "127.0.0.3:2181",
Username: "user1",
Password: "pwd1",
},
{
Id: "hangzhou_reg2",
Type: "mock",
TimeoutStr: "2s",
Group: "hangzhou_idc",
Address: "127.0.0.4:2181",
Username: "user1",
Password: "pwd1",
},
},
Services: []ServiceConfig{
{
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
Protocol: "mock",
Registries: []ConfigRegistry{"shanghai_reg1", "shanghai_reg2", "hangzhou_reg1", "hangzhou_reg2"},
Cluster: "failover",
Loadbalance: "random",
Retries: 3,
Group: "huadong_idc",
Version: "1.0.0",
Methods: []struct {
Name string `yaml:"name" json:"name,omitempty"`
Retries int64 `yaml:"retries" json:"retries,omitempty"`
Loadbalance string `yaml:"loadbalance" json:"loadbalance,omitempty"`
Weight int64 `yaml:"weight" json:"weight,omitempty"`
}{
{
Name: "GetUser",
Retries: 2,
Loadbalance: "random",
Weight: 200,
},
{
Name: "GetUser1",
Retries: 2,
Loadbalance: "random",
Weight: 200,
},
},
},
},
Protocols: []ProtocolConfig{
{
Name: "mock",
Ip: "127.0.0.1",
Port: "20000",
ContextPath: "/xxx",
},
},
}
}
func Test_Export(t *testing.T) {
doinit()
extension.SetProtocol("registry", GetProtocol)
for _, service := range providerConfig.Services {
service.Implement(&MockService{})
service.Export()
assert.Condition(t, func() bool {
return len(service.exporters) > 0
})
}
providerConfig = nil
}