3
3
import com .crossoverjie .cim .client .sdk .impl .ClientConfigurationData ;
4
4
import com .crossoverjie .cim .client .sdk .io .backoff .RandomBackoff ;
5
5
import com .crossoverjie .cim .client .sdk .route .AbstractRouteBaseTest ;
6
+ import com .crossoverjie .cim .common .constant .Constants ;
6
7
import com .crossoverjie .cim .common .pojo .CIMUserInfo ;
7
8
import com .crossoverjie .cim .route .api .vo .req .P2PReqVO ;
8
9
import com .crossoverjie .cim .route .api .vo .res .CIMServerResVO ;
@@ -63,7 +64,11 @@ public void groupChat() throws Exception {
63
64
Client client2 = Client .builder ()
64
65
.auth (auth2 )
65
66
.routeUrl (routeUrl )
66
- .messageListener ((client , message ) -> client2Receive .set (message ))
67
+ .messageListener ((client , properties , message ) -> {
68
+ client2Receive .set (message );
69
+ Assertions .assertEquals (properties .get (Constants .MetaKey .USER_ID ), String .valueOf (auth1 .getUserId ()));
70
+ Assertions .assertEquals (properties .get (Constants .MetaKey .USER_NAME ), auth1 .getUserName ());
71
+ })
67
72
.build ();
68
73
TimeUnit .SECONDS .sleep (3 );
69
74
ClientState .State state2 = client2 .getState ();
@@ -91,7 +96,7 @@ public void groupChat() throws Exception {
91
96
});
92
97
93
98
Awaitility .await ().untilAsserted (
94
- () -> Assertions .assertEquals (String . format ( "crossoverJie:%s" , msg ) , client2Receive .get ()));
99
+ () -> Assertions .assertEquals (msg , client2Receive .get ()));
95
100
super .stopSingle ();
96
101
}
97
102
@@ -139,7 +144,7 @@ public void testP2PChat() throws Exception {
139
144
Client client2 = Client .builder ()
140
145
.auth (auth2 )
141
146
.routeUrl (routeUrl )
142
- .messageListener ((client , message ) -> client2Receive .set (message ))
147
+ .messageListener ((client , properties , message ) -> client2Receive .set (message ))
143
148
.build ();
144
149
TimeUnit .SECONDS .sleep (3 );
145
150
ClientState .State state2 = client2 .getState ();
@@ -156,7 +161,7 @@ public void testP2PChat() throws Exception {
156
161
Client client3 = Client .builder ()
157
162
.auth (auth3 )
158
163
.routeUrl (routeUrl )
159
- .messageListener ((client , message ) -> {
164
+ .messageListener ((client , properties , message ) -> {
160
165
log .info ("client3 receive message = {}" , message );
161
166
client3Receive .set (message );
162
167
})
@@ -192,7 +197,7 @@ public void testP2PChat() throws Exception {
192
197
});
193
198
194
199
Awaitility .await ().untilAsserted (
195
- () -> Assertions .assertEquals (String . format ( "%s:%s" , cj , msg ) , client3Receive .get ()));
200
+ () -> Assertions .assertEquals (msg , client3Receive .get ()));
196
201
Awaitility .await ().untilAsserted (
197
202
() -> Assertions .assertNull (client2Receive .get ()));
198
203
super .stopSingle ();
@@ -244,7 +249,7 @@ public void testReconnect() throws Exception {
244
249
Client client2 = Client .builder ()
245
250
.auth (auth2 )
246
251
.routeUrl (routeUrl )
247
- .messageListener ((client , message ) -> client2Receive .set (message ))
252
+ .messageListener ((client , properties , message ) -> client2Receive .set (message ))
248
253
.backoffStrategy (backoffStrategy )
249
254
.build ();
250
255
TimeUnit .SECONDS .sleep (3 );
@@ -260,7 +265,7 @@ public void testReconnect() throws Exception {
260
265
String msg = "hello" ;
261
266
client1 .sendGroup (msg );
262
267
Awaitility .await ()
263
- .untilAsserted (() -> Assertions .assertEquals (String . format ( "cj:%s" , msg ) , client2Receive .get ()));
268
+ .untilAsserted (() -> Assertions .assertEquals (msg , client2Receive .get ()));
264
269
client2Receive .set ("" );
265
270
266
271
@@ -287,7 +292,7 @@ public void testReconnect() throws Exception {
287
292
log .info ("send message again, client2Receive = {}" , client2Receive .get ());
288
293
client1 .sendGroup (msg );
289
294
Awaitility .await ()
290
- .untilAsserted (() -> Assertions .assertEquals (String . format ( "cj:%s" , msg ) , client2Receive .get ()));
295
+ .untilAsserted (() -> Assertions .assertEquals (msg , client2Receive .get ()));
291
296
super .stopTwoServer ();
292
297
}
293
298
@@ -327,7 +332,7 @@ public void offLineAndOnline() throws Exception {
327
332
Client client2 = Client .builder ()
328
333
.auth (auth2 )
329
334
.routeUrl (routeUrl )
330
- .messageListener ((client , message ) -> client2Receive .set (message ))
335
+ .messageListener ((client , properties , message ) -> client2Receive .set (message ))
331
336
// Avoid auto reconnect, this test will manually close client.
332
337
.reconnectCheck ((client ) -> false )
333
338
.build ();
@@ -344,7 +349,7 @@ public void offLineAndOnline() throws Exception {
344
349
String msg = "hello" ;
345
350
client1 .sendGroup (msg );
346
351
Awaitility .await ().untilAsserted (
347
- () -> Assertions .assertEquals (String . format ( "crossoverJie:%s" , msg ) , client2Receive .get ()));
352
+ () -> Assertions .assertEquals (msg , client2Receive .get ()));
348
353
client2Receive .set ("" );
349
354
350
355
// Manually offline
@@ -353,7 +358,7 @@ public void offLineAndOnline() throws Exception {
353
358
client2 = Client .builder ()
354
359
.auth (auth2 )
355
360
.routeUrl (routeUrl )
356
- .messageListener ((client , message ) -> client2Receive .set (message ))
361
+ .messageListener ((client , properties , message ) -> client2Receive .set (message ))
357
362
// Avoid to auto reconnect, this test will manually close client.
358
363
.reconnectCheck ((client ) -> false )
359
364
.build ();
@@ -364,7 +369,7 @@ public void offLineAndOnline() throws Exception {
364
369
// send msg again
365
370
client1 .sendGroup (msg );
366
371
Awaitility .await ().untilAsserted (
367
- () -> Assertions .assertEquals (String . format ( "crossoverJie:%s" , msg ) , client2Receive .get ()));
372
+ () -> Assertions .assertEquals (msg , client2Receive .get ()));
368
373
369
374
super .stopSingle ();
370
375
}
0 commit comments