Skip to content

Commit 24bc616

Browse files
author
clininger
committed
test name changes; fixed test assertions; POM modules added
1 parent e00bfcf commit 24bc616

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@
483483

484484
<module>reactor-core</module>
485485
<module>resteasy</module>
486+
<module>rsocket</module>
486487
<module>rxjava</module>
487488
<module>rxjava-2</module>
488489
<module>rabbitmq</module>
@@ -1036,6 +1037,7 @@
10361037

10371038
<module>reactor-core</module>
10381039
<module>resteasy</module>
1040+
<module>rsocket</module>
10391041
<module>rxjava</module>
10401042
<module>rxjava-2</module>
10411043
<module>rabbitmq</module>

rsocket/src/test/java/com/baeldung/rsocket/RSocketIntegrationTest.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.baeldung.rsocket;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45
import org.junit.AfterClass;
56
import org.junit.BeforeClass;
@@ -29,28 +30,35 @@ public static void tearDownClass() {
2930
}
3031

3132
@Test
32-
public void testRequestResponse() {
33+
public void whenSendingAString_thenRevceiveTheSameString() {
3334
ReqResClient client = new ReqResClient();
3435
String string = "Hello RSocket";
3536
assertEquals(string, client.callBlocking(string));
3637
client.dispose();
3738
}
3839

3940
@Test
40-
public void testFNFAndRequestStream() {
41+
public void whenSendingStream_thenReceiveTheSameStream() {
4142
// create the client that pushes data to the server and start sending
4243
FireNForgetClient fnfClient = new FireNForgetClient();
44+
// create a client to read a stream from the server and subscribe to events
45+
ReqStreamClient streamClient = new ReqStreamClient();
46+
4347
// get the data that is used by the client
4448
List<Float> data = fnfClient.getData();
49+
// create a place to count the results
50+
List<Float> dataReceived = new ArrayList<>();
4551

46-
// create a client to read a stream from the server and subscribe to events
47-
ReqStreamClient streamClient = new ReqStreamClient();
4852
// assert that the data received is the same as the data sent
4953
Disposable subscription = streamClient.getDataStream()
50-
.index()
51-
.doOnNext(element -> assertEquals(data.get(element.getT1().intValue()), element.getT2()))
52-
.count()
53-
.subscribe(count -> assertEquals(data.size(), count.intValue()));
54+
.index()
55+
.subscribe(
56+
tuple -> {
57+
assertEquals("Wrong value", data.get(tuple.getT1().intValue()), tuple.getT2());
58+
dataReceived.add(tuple.getT2());
59+
},
60+
err -> LOG.error(err.getMessage())
61+
);
5462

5563
// start sending the data
5664
fnfClient.sendData();
@@ -59,10 +67,13 @@ public void testFNFAndRequestStream() {
5967
try { Thread.sleep(500); } catch (Exception x) {}
6068
subscription.dispose();
6169
fnfClient.dispose();
70+
71+
// verify the item count
72+
assertEquals("Wrong data count received", data.size(), dataReceived.size());
6273
}
6374

6475
@Test
65-
public void testChannel() {
76+
public void whenRunningChannelGame_thenLogTheResults() {
6677
ChannelClient client = new ChannelClient();
6778
client.playGame();
6879
client.dispose();

0 commit comments

Comments
 (0)