Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
cd01f71b
R
Rocketmq
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cd01f71b
编写于
1月 23, 2017
作者:
S
stevenschew
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ROCKETMQ-54] Polish unit test for DefaultRequestProcessor
上级
a3aa00a2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
1 deletion
+33
-1
namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessorTest.java
...cketmq/namesrv/processor/DefaultRequestProcessorTest.java
+33
-1
未找到文件。
namesrv/src/test/java/org/apache/rocketmq/namesrv/processor/DefaultRequestProcessorTest.java
浏览文件 @
cd01f71b
...
@@ -16,14 +16,20 @@
...
@@ -16,14 +16,20 @@
*/
*/
package
org.apache.rocketmq.namesrv.processor
;
package
org.apache.rocketmq.namesrv.processor
;
import
io.netty.channel.Channel
;
import
io.netty.channel.ChannelHandlerContext
;
import
io.netty.channel.ChannelHandlerContext
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Modifier
;
import
java.lang.reflect.Modifier
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.apache.rocketmq.common.TopicConfig
;
import
org.apache.rocketmq.common.namesrv.NamesrvConfig
;
import
org.apache.rocketmq.common.namesrv.NamesrvConfig
;
import
org.apache.rocketmq.common.namesrv.RegisterBrokerResult
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
import
org.apache.rocketmq.common.protocol.body.TopicConfigSerializeWrapper
;
import
org.apache.rocketmq.common.protocol.header.namesrv.DeleteKVConfigRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.namesrv.DeleteKVConfigRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader
;
import
org.apache.rocketmq.common.protocol.header.namesrv.GetKVConfigResponseHeader
;
...
@@ -53,16 +59,25 @@ public class DefaultRequestProcessorTest {
...
@@ -53,16 +59,25 @@ public class DefaultRequestProcessorTest {
private
NettyServerConfig
nettyServerConfig
;
private
NettyServerConfig
nettyServerConfig
;
private
RouteInfoManager
routeInfoManager
;
private
Logger
logger
;
private
Logger
logger
;
@Before
@Before
public
void
init
()
throws
Exception
{
public
void
init
()
throws
Exception
{
namesrvConfig
=
new
NamesrvConfig
();
namesrvConfig
=
new
NamesrvConfig
();
nettyServerConfig
=
new
NettyServerConfig
();
nettyServerConfig
=
new
NettyServerConfig
();
routeInfoManager
=
new
RouteInfoManager
();
namesrvController
=
new
NamesrvController
(
namesrvConfig
,
nettyServerConfig
);
namesrvController
=
new
NamesrvController
(
namesrvConfig
,
nettyServerConfig
);
Field
field
=
NamesrvController
.
class
.
getDeclaredField
(
"routeInfoManager"
);
field
.
setAccessible
(
true
);
field
.
set
(
namesrvController
,
routeInfoManager
);
defaultRequestProcessor
=
new
DefaultRequestProcessor
(
namesrvController
);
defaultRequestProcessor
=
new
DefaultRequestProcessor
(
namesrvController
);
registerRouteInfoManager
();
logger
=
mock
(
Logger
.
class
);
logger
=
mock
(
Logger
.
class
);
when
(
logger
.
isInfoEnabled
()).
thenReturn
(
false
);
when
(
logger
.
isInfoEnabled
()).
thenReturn
(
false
);
setFinalStatic
(
DefaultRequestProcessor
.
class
.
getDeclaredField
(
"log"
),
logger
);
setFinalStatic
(
DefaultRequestProcessor
.
class
.
getDeclaredField
(
"log"
),
logger
);
...
@@ -218,7 +233,7 @@ public class DefaultRequestProcessorTest {
...
@@ -218,7 +233,7 @@ public class DefaultRequestProcessorTest {
Field
brokerAddrTable
=
RouteInfoManager
.
class
.
getDeclaredField
(
"brokerAddrTable"
);
Field
brokerAddrTable
=
RouteInfoManager
.
class
.
getDeclaredField
(
"brokerAddrTable"
);
brokerAddrTable
.
setAccessible
(
true
);
brokerAddrTable
.
setAccessible
(
true
);
assertThat
((
Map
)
brokerAddrTable
.
get
(
routes
)).
isEmpty
();
assertThat
((
Map
)
brokerAddrTable
.
get
(
routes
)).
is
Not
Empty
();
}
}
private
static
RemotingCommand
genSampleRegisterCmd
(
boolean
reg
)
{
private
static
RemotingCommand
genSampleRegisterCmd
(
boolean
reg
)
{
...
@@ -241,4 +256,21 @@ public class DefaultRequestProcessorTest {
...
@@ -241,4 +256,21 @@ public class DefaultRequestProcessorTest {
modifiersField
.
setInt
(
field
,
field
.
getModifiers
()
&
~
Modifier
.
FINAL
);
modifiersField
.
setInt
(
field
,
field
.
getModifiers
()
&
~
Modifier
.
FINAL
);
field
.
set
(
null
,
newValue
);
field
.
set
(
null
,
newValue
);
}
}
private
void
registerRouteInfoManager
()
{
TopicConfigSerializeWrapper
topicConfigSerializeWrapper
=
new
TopicConfigSerializeWrapper
();
ConcurrentHashMap
<
String
,
TopicConfig
>
topicConfigConcurrentHashMap
=
new
ConcurrentHashMap
<>();
TopicConfig
topicConfig
=
new
TopicConfig
();
topicConfig
.
setWriteQueueNums
(
8
);
topicConfig
.
setTopicName
(
"unit-test"
);
topicConfig
.
setPerm
(
6
);
topicConfig
.
setReadQueueNums
(
8
);
topicConfig
.
setOrder
(
false
);
topicConfigConcurrentHashMap
.
put
(
"unit-test"
,
topicConfig
);
topicConfigSerializeWrapper
.
setTopicConfigTable
(
topicConfigConcurrentHashMap
);
Channel
channel
=
mock
(
Channel
.
class
);
RegisterBrokerResult
registerBrokerResult
=
routeInfoManager
.
registerBroker
(
"default-cluster"
,
"127.0.0.1:10911"
,
"default-broker"
,
1234
,
"127.0.0.1:1001"
,
topicConfigSerializeWrapper
,
new
ArrayList
<
String
>(),
channel
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录