Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yanghaoyuan.sh
SkyWalking
提交
6d6310bf
S
SkyWalking
项目概览
yanghaoyuan.sh
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d6310bf
编写于
7月 10, 2018
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into 6.0
上级
c81a4a30
d0f15fc3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
101 addition
and
0 deletion
+101
-0
apm-webapp/pom.xml
apm-webapp/pom.xml
+6
-0
apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/proxy/NIWSServerListTest.java
...pache/skywalking/apm/webapp/proxy/NIWSServerListTest.java
+95
-0
未找到文件。
apm-webapp/pom.xml
浏览文件 @
6d6310bf
...
...
@@ -88,6 +88,12 @@
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-zuul
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<version>
${spring.boot.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
...
...
apm-webapp/src/test/java/org/apache/skywalking/apm/webapp/proxy/NIWSServerListTest.java
0 → 100644
浏览文件 @
6d6310bf
/*
* 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
org.apache.skywalking.apm.webapp.proxy
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.core.env.AbstractEnvironment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.ServerList
;
import
com.netflix.loadbalancer.ZoneAwareLoadBalancer
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
@DirtiesContext
public
class
NIWSServerListTest
{
@Autowired
private
Environment
env
;
@Autowired
private
SpringClientFactory
factory
;
private
Map
<
String
,
String
>
serverListClassNames
=
new
HashMap
<
String
,
String
>();
@Before
public
void
initServerListClassNames
()
{
for
(
Iterator
<?>
iter
=
((
AbstractEnvironment
)
env
).
getPropertySources
().
iterator
();
iter
.
hasNext
();)
{
Object
propertySource
=
iter
.
next
();
if
(
propertySource
instanceof
MapPropertySource
)
{
Map
<
String
,
Object
>
mapPropertySource
=
((
MapPropertySource
)
propertySource
).
getSource
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
mapPropertySource
.
entrySet
())
{
String
key
=
entry
.
getKey
();
int
index
;
if
(
key
.
endsWith
(
".NIWSServerListClassName"
)
&&
(
index
=
key
.
indexOf
(
".ribbon"
))
>
0
)
{
String
clientName
=
key
.
substring
(
0
,
index
);
serverListClassNames
.
put
(
clientName
,(
String
)
entry
.
getValue
());
}
}
}
}
}
@Test
public
void
serverListClass
()
throws
ClassNotFoundException
{
for
(
String
serverListClassName
:
serverListClassNames
.
values
())
{
Class
<?>
clazz
=
Class
.
forName
(
serverListClassName
);
}
}
@Test
public
void
serverListFliter
()
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
serverListClassNames
.
entrySet
())
{
String
clientName
=
entry
.
getKey
();
String
serverListClassName
=
entry
.
getValue
();
ServerList
<
Server
>
serverList
=
getLoadBalancer
(
clientName
).
getServerListImpl
();
assertNotNull
(
"Client: "
+
clientName
+
"'s ServerListImpl is null"
,
serverList
);
assertEquals
(
"Clinet: "
+
clientName
+
"'s ServerListImpl not Same with setting in configs"
,
serverListClassName
,
serverList
.
getClass
().
getName
());
}
}
@SuppressWarnings
(
"unchecked"
)
private
ZoneAwareLoadBalancer
<
Server
>
getLoadBalancer
(
String
name
)
{
return
(
ZoneAwareLoadBalancer
<
Server
>)
this
.
factory
.
getLoadBalancer
(
name
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录