Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
bbcb69ec
R
Rocketmq
项目概览
小五666\n哈哈
/
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看板
提交
bbcb69ec
编写于
1月 17, 2017
作者:
Y
yukon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ROCKETMQ-52] Use MockitoJUnitRunner with Mock
上级
032bb2b3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
34 deletion
+30
-34
client/src/test/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStoreTest.java
...ketmq/client/consumer/store/LocalFileOffsetStoreTest.java
+10
-9
client/src/test/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStoreTest.java
...mq/client/consumer/store/RemoteBrokerOffsetStoreTest.java
+11
-12
client/src/test/java/org/apache/rocketmq/client/impl/MQClientAPIImplTest.java
.../org/apache/rocketmq/client/impl/MQClientAPIImplTest.java
+9
-10
client/src/test/java/org/apache/rocketmq/client/impl/factory/MQClientInstanceTest.java
...he/rocketmq/client/impl/factory/MQClientInstanceTest.java
+0
-3
未找到文件。
client/src/test/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStoreTest.java
浏览文件 @
bbcb69ec
...
...
@@ -21,25 +21,26 @@ import java.util.HashSet;
import
org.apache.rocketmq.client.ClientConfig
;
import
org.apache.rocketmq.client.impl.factory.MQClientInstance
;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.junit.Before
Class
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.
Mockito
;
import
org.mockito.
junit.MockitoJUnitRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
LocalFileOffsetStoreTest
{
@Mock
private
static
MQClientInstance
mQClientFactory
;
private
static
String
group
=
"FooBarGroup"
;
private
static
String
topic
=
"FooBar"
;
private
static
String
brokerName
=
"DefaultBrokerName"
;
private
MQClientInstance
mQClientFactory
;
private
String
group
=
"FooBarGroup"
;
private
String
topic
=
"FooBar"
;
private
String
brokerName
=
"DefaultBrokerName"
;
@Before
Class
public
static
void
init
()
{
@Before
public
void
init
()
{
System
.
setProperty
(
"rocketmq.client.localOffsetStoreDir"
,
System
.
getProperty
(
"java.io.tmpdir"
)
+
".rocketmq_offsets"
);
mQClientFactory
=
Mockito
.
mock
(
MQClientInstance
.
class
);
String
clientId
=
new
ClientConfig
().
buildMQClientId
()
+
"#TestNamespace"
+
System
.
currentTimeMillis
();
when
(
mQClientFactory
.
getClientId
()).
thenReturn
(
clientId
);
}
...
...
client/src/test/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStoreTest.java
浏览文件 @
bbcb69ec
...
...
@@ -27,10 +27,12 @@ import org.apache.rocketmq.common.message.MessageQueue;
import
org.apache.rocketmq.common.protocol.header.QueryConsumerOffsetRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.UpdateConsumerOffsetRequestHeader
;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
import
org.junit.Before
Class
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.mockito.stubbing.Answer
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -39,27 +41,24 @@ import static org.mockito.ArgumentMatchers.anyLong;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
RemoteBrokerOffsetStoreTest
{
@Mock
private
static
MQClientInstance
mQClientFactory
;
private
MQClientInstance
mQClientFactory
;
@Mock
private
static
MQClientAPIImpl
mqClientAPI
;
private
static
String
group
=
"FooBarGroup"
;
private
static
String
topic
=
"FooBar"
;
private
static
String
brokerName
=
"DefaultBrokerName"
;
private
MQClientAPIImpl
mqClientAPI
;
private
String
group
=
"FooBarGroup"
;
private
String
topic
=
"FooBar"
;
private
String
brokerName
=
"DefaultBrokerName"
;
@Before
Class
public
static
void
init
()
{
@Before
public
void
init
()
{
System
.
setProperty
(
"rocketmq.client.localOffsetStoreDir"
,
System
.
getProperty
(
"java.io.tmpdir"
)
+
".rocketmq_offsets"
);
mQClientFactory
=
mock
(
MQClientInstance
.
class
);
String
clientId
=
new
ClientConfig
().
buildMQClientId
()
+
"#TestNamespace"
+
System
.
currentTimeMillis
();
when
(
mQClientFactory
.
getClientId
()).
thenReturn
(
clientId
);
when
(
mQClientFactory
.
findBrokerAddressInAdmin
(
brokerName
)).
thenReturn
(
new
FindBrokerResult
(
"127.0.0.1"
,
false
));
mqClientAPI
=
mock
(
MQClientAPIImpl
.
class
);
when
(
mQClientFactory
.
getMQClientAPIImpl
()).
thenReturn
(
mqClientAPI
);
}
...
...
client/src/test/java/org/apache/rocketmq/client/impl/MQClientAPIImplTest.java
浏览文件 @
bbcb69ec
...
...
@@ -35,13 +35,14 @@ import org.apache.rocketmq.remoting.RemotingClient;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
import
org.apache.rocketmq.remoting.exception.RemotingTimeoutException
;
import
org.apache.rocketmq.remoting.netty.NettyClientConfig
;
import
org.apache.rocketmq.remoting.netty.NettyRemotingClient
;
import
org.apache.rocketmq.remoting.netty.ResponseFuture
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.junit.Before
Class
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.invocation.InvocationOnMock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.mockito.stubbing.Answer
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -52,14 +53,14 @@ import static org.mockito.ArgumentMatchers.anyString;
import
static
org
.
mockito
.
Mockito
.
doAnswer
;
import
static
org
.
mockito
.
Mockito
.
doNothing
;
import
static
org
.
mockito
.
Mockito
.
doThrow
;
import
static
org
.
mockito
.
Mockito
.
mock
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
MQClientAPIImplTest
{
private
static
MQClientAPIImpl
mqClientAPI
=
new
MQClientAPIImpl
(
new
NettyClientConfig
(),
null
,
null
,
new
ClientConfig
());
private
MQClientAPIImpl
mqClientAPI
=
new
MQClientAPIImpl
(
new
NettyClientConfig
(),
null
,
null
,
new
ClientConfig
());
@Mock
private
static
RemotingClient
remotingClient
;
private
RemotingClient
remotingClient
;
@Mock
private
static
DefaultMQProducerImpl
defaultMQProducerImpl
;
private
DefaultMQProducerImpl
defaultMQProducerImpl
;
private
String
brokerAddr
=
"127.0.0.1"
;
private
String
brokerName
=
"DefaultBroker"
;
...
...
@@ -67,10 +68,8 @@ public class MQClientAPIImplTest {
private
static
String
topic
=
"FooBar"
;
private
Message
msg
=
new
Message
(
"FooBar"
,
new
byte
[]
{});
@BeforeClass
public
static
void
init
()
throws
Exception
{
remotingClient
=
mock
(
NettyRemotingClient
.
class
);
defaultMQProducerImpl
=
mock
(
DefaultMQProducerImpl
.
class
);
@Before
public
void
init
()
throws
Exception
{
Field
field
=
MQClientAPIImpl
.
class
.
getDeclaredField
(
"remotingClient"
);
field
.
setAccessible
(
true
);
field
.
set
(
mqClientAPI
,
remotingClient
);
...
...
client/src/test/java/org/apache/rocketmq/client/impl/factory/MQClientInstanceTest.java
浏览文件 @
bbcb69ec
...
...
@@ -32,7 +32,6 @@ import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -40,9 +39,7 @@ import static org.mockito.Mockito.mock;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
MQClientInstanceTest
{
@InjectMocks
private
MQClientInstance
mqClientInstance
=
MQClientManager
.
getInstance
().
getAndCreateMQClientInstance
(
new
ClientConfig
());;
private
String
topic
=
"FooBar"
;
private
String
group
=
"FooBarGroup"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录