Skip to content

Commit 640a322

Browse files
githublaohuShannonDing
authored andcommitted
change ResponseFutureTest (#159)
1 parent a14580f commit 640a322

File tree

1 file changed

+5
-62
lines changed

1 file changed

+5
-62
lines changed

test/src/transport/ResponseFutureTest.cpp

Lines changed: 5 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using ::testing::InitGoogleTest;
3232
using testing::Return;
3333

3434
using rocketmq::AsyncCallback;
35-
using rocketmq::asyncCallBackStatus;
35+
using rocketmq::AsyncCallbackStatus;
3636
using rocketmq::asyncCallBackType;
3737
using rocketmq::AsyncCallbackWrap;
3838
using rocketmq::MQClientAPIImpl;
@@ -64,26 +64,19 @@ TEST(responseFuture, init) {
6464
EXPECT_EQ(responseFuture.getRetrySendTimes(), 1);
6565
EXPECT_EQ(responseFuture.getBrokerAddr(), "");
6666

67-
EXPECT_FALSE(responseFuture.getASyncFlag());
68-
EXPECT_TRUE(responseFuture.getAsyncResponseFlag());
69-
EXPECT_FALSE(responseFuture.getSyncResponseFlag());
67+
EXPECT_FALSE(responseFuture.getAsyncFlag());
7068
EXPECT_TRUE(responseFuture.getAsyncCallbackWrap() == nullptr);
7169

7270
// ~ResponseFuture delete pcall
7371
SendCallbackWrap* pcall = new SendCallbackWrap("", MQMessage(), nullptr, nullptr);
7472
ResponseFuture twoResponseFuture(13, 4, nullptr, 1000, true, pcall);
75-
EXPECT_TRUE(twoResponseFuture.getASyncFlag());
76-
EXPECT_FALSE(twoResponseFuture.getAsyncResponseFlag());
77-
EXPECT_TRUE(twoResponseFuture.getSyncResponseFlag());
73+
EXPECT_TRUE(twoResponseFuture.getAsyncFlag());
7874
EXPECT_FALSE(twoResponseFuture.getAsyncCallbackWrap() == nullptr);
7975
}
8076

8177
TEST(responseFuture, info) {
8278
ResponseFuture responseFuture(13, 4, NULL, 1000);
8379

84-
responseFuture.setAsyncResponseFlag();
85-
EXPECT_TRUE(responseFuture.getAsyncResponseFlag());
86-
8780
responseFuture.setBrokerAddr("127.0.0.1:9876");
8881
EXPECT_EQ(responseFuture.getBrokerAddr(), "127.0.0.1:9876");
8982

@@ -101,25 +94,15 @@ TEST(responseFuture, response) {
10194
// m_bAsync = false m_syncResponse
10295
ResponseFuture responseFuture(13, 4, NULL, 1000);
10396

104-
EXPECT_FALSE(responseFuture.getASyncFlag());
105-
EXPECT_FALSE(responseFuture.getSyncResponseFlag());
106-
EXPECT_TRUE(responseFuture.getAsyncResponseFlag());
97+
EXPECT_FALSE(responseFuture.getAsyncFlag());
10798

10899
RemotingCommand* pResponseCommand = NULL;
109100
responseFuture.setResponse(pResponseCommand);
110101
EXPECT_EQ(responseFuture.getRequestCommand().getCode(), 0);
111102

112-
EXPECT_TRUE(responseFuture.getSyncResponseFlag());
113-
114103
// m_bAsync = true m_syncResponse
115104
ResponseFuture twoResponseFuture(13, 4, NULL, 1000, true);
116-
117-
EXPECT_TRUE(twoResponseFuture.getASyncFlag());
118-
EXPECT_TRUE(twoResponseFuture.getSyncResponseFlag());
119-
EXPECT_FALSE(twoResponseFuture.getAsyncResponseFlag());
120-
121-
twoResponseFuture.setResponse(pResponseCommand);
122-
EXPECT_TRUE(twoResponseFuture.getSyncResponseFlag());
105+
EXPECT_TRUE(twoResponseFuture.getAsyncFlag());
123106

124107
ResponseFuture threeSesponseFuture(13, 4, NULL, 1000);
125108

@@ -128,49 +111,9 @@ TEST(responseFuture, response) {
128111
uint64_t useTime = UtilAll::currentTimeMillis() - millis;
129112
EXPECT_LT(useTime, 30);
130113

131-
EXPECT_TRUE(responseFuture.getSyncResponseFlag());
132114
EXPECT_EQ(NULL, remotingCommand);
133115
}
134116

135-
TEST(responseFuture, executeInvokeCallback) {
136-
// executeInvokeCallback delete wrap
137-
MockAsyncCallbackWrap* wrap = new MockAsyncCallbackWrap(nullptr, nullptr);
138-
ResponseFuture responseFuture(13, 4, nullptr, 1000, false, wrap);
139-
140-
RemotingCommand* pResponseCommand = new RemotingCommand();
141-
responseFuture.setResponse(pResponseCommand);
142-
responseFuture.executeInvokeCallback();
143-
EXPECT_EQ(NULL, responseFuture.getCommand());
144-
145-
EXPECT_CALL(*wrap, operationComplete(_, _)).Times(1);
146-
pResponseCommand = new RemotingCommand();
147-
responseFuture.setResponse(pResponseCommand);
148-
responseFuture.setAsyncCallBackStatus(asyncCallBackStatus::asyncCallBackStatus_response);
149-
responseFuture.executeInvokeCallback();
150-
EXPECT_EQ(pResponseCommand->getCode(), 0);
151-
152-
ResponseFuture twoResponseFuture(13, 4, nullptr, 1000, false, NULL);
153-
pResponseCommand = new RemotingCommand();
154-
twoResponseFuture.executeInvokeCallback();
155-
EXPECT_EQ(NULL, twoResponseFuture.getCommand());
156-
}
157-
158-
TEST(responseFuture, executeInvokeCallbackException) {
159-
// executeInvokeCallbackException delete wrap
160-
MockAsyncCallbackWrap* wrap = new MockAsyncCallbackWrap(nullptr, nullptr);
161-
162-
ResponseFuture responseFuture(13, 4, nullptr, 1000, false, wrap);
163-
164-
EXPECT_CALL(*wrap, onException()).Times(1);
165-
responseFuture.executeInvokeCallbackException();
166-
167-
responseFuture.setAsyncCallBackStatus(asyncCallBackStatus::asyncCallBackStatus_timeout);
168-
responseFuture.executeInvokeCallbackException();
169-
170-
ResponseFuture twoRresponseFuture(13, 4, nullptr, 1000, false, NULL);
171-
twoRresponseFuture.executeInvokeCallbackException();
172-
}
173-
174117
int main(int argc, char* argv[]) {
175118
InitGoogleMock(&argc, argv);
176119
testing::GTEST_FLAG(throw_on_failure) = true;

0 commit comments

Comments
 (0)