@@ -32,7 +32,7 @@ using ::testing::InitGoogleTest;
32
32
using testing::Return;
33
33
34
34
using rocketmq::AsyncCallback;
35
- using rocketmq::asyncCallBackStatus ;
35
+ using rocketmq::AsyncCallbackStatus ;
36
36
using rocketmq::asyncCallBackType;
37
37
using rocketmq::AsyncCallbackWrap;
38
38
using rocketmq::MQClientAPIImpl;
@@ -64,26 +64,19 @@ TEST(responseFuture, init) {
64
64
EXPECT_EQ (responseFuture.getRetrySendTimes (), 1 );
65
65
EXPECT_EQ (responseFuture.getBrokerAddr (), " " );
66
66
67
- EXPECT_FALSE (responseFuture.getASyncFlag ());
68
- EXPECT_TRUE (responseFuture.getAsyncResponseFlag ());
69
- EXPECT_FALSE (responseFuture.getSyncResponseFlag ());
67
+ EXPECT_FALSE (responseFuture.getAsyncFlag ());
70
68
EXPECT_TRUE (responseFuture.getAsyncCallbackWrap () == nullptr );
71
69
72
70
// ~ResponseFuture delete pcall
73
71
SendCallbackWrap* pcall = new SendCallbackWrap (" " , MQMessage (), nullptr , nullptr );
74
72
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 ());
78
74
EXPECT_FALSE (twoResponseFuture.getAsyncCallbackWrap () == nullptr );
79
75
}
80
76
81
77
TEST (responseFuture, info) {
82
78
ResponseFuture responseFuture (13 , 4 , NULL , 1000 );
83
79
84
- responseFuture.setAsyncResponseFlag ();
85
- EXPECT_TRUE (responseFuture.getAsyncResponseFlag ());
86
-
87
80
responseFuture.setBrokerAddr (" 127.0.0.1:9876" );
88
81
EXPECT_EQ (responseFuture.getBrokerAddr (), " 127.0.0.1:9876" );
89
82
@@ -101,25 +94,15 @@ TEST(responseFuture, response) {
101
94
// m_bAsync = false m_syncResponse
102
95
ResponseFuture responseFuture (13 , 4 , NULL , 1000 );
103
96
104
- EXPECT_FALSE (responseFuture.getASyncFlag ());
105
- EXPECT_FALSE (responseFuture.getSyncResponseFlag ());
106
- EXPECT_TRUE (responseFuture.getAsyncResponseFlag ());
97
+ EXPECT_FALSE (responseFuture.getAsyncFlag ());
107
98
108
99
RemotingCommand* pResponseCommand = NULL ;
109
100
responseFuture.setResponse (pResponseCommand);
110
101
EXPECT_EQ (responseFuture.getRequestCommand ().getCode (), 0 );
111
102
112
- EXPECT_TRUE (responseFuture.getSyncResponseFlag ());
113
-
114
103
// m_bAsync = true m_syncResponse
115
104
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 ());
123
106
124
107
ResponseFuture threeSesponseFuture (13 , 4 , NULL , 1000 );
125
108
@@ -128,49 +111,9 @@ TEST(responseFuture, response) {
128
111
uint64_t useTime = UtilAll::currentTimeMillis () - millis;
129
112
EXPECT_LT (useTime, 30 );
130
113
131
- EXPECT_TRUE (responseFuture.getSyncResponseFlag ());
132
114
EXPECT_EQ (NULL , remotingCommand);
133
115
}
134
116
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
-
174
117
int main (int argc, char * argv[]) {
175
118
InitGoogleMock (&argc, argv);
176
119
testing::GTEST_FLAG (throw_on_failure) = true ;
0 commit comments