commit
bbdc8abc14
2
pom.xml
2
pom.xml
@ -483,6 +483,7 @@
|
|||||||
|
|
||||||
<module>reactor-core</module>
|
<module>reactor-core</module>
|
||||||
<module>resteasy</module>
|
<module>resteasy</module>
|
||||||
|
<module>rsocket</module>
|
||||||
<module>rxjava</module>
|
<module>rxjava</module>
|
||||||
<module>rxjava-2</module>
|
<module>rxjava-2</module>
|
||||||
<module>rabbitmq</module>
|
<module>rabbitmq</module>
|
||||||
@ -1036,6 +1037,7 @@
|
|||||||
|
|
||||||
<module>reactor-core</module>
|
<module>reactor-core</module>
|
||||||
<module>resteasy</module>
|
<module>resteasy</module>
|
||||||
|
<module>rsocket</module>
|
||||||
<module>rxjava</module>
|
<module>rxjava</module>
|
||||||
<module>rxjava-2</module>
|
<module>rxjava-2</module>
|
||||||
<module>rabbitmq</module>
|
<module>rabbitmq</module>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.baeldung.rsocket;
|
package com.baeldung.rsocket;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
@ -29,7 +30,7 @@ public class RSocketIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRequestResponse() {
|
public void whenSendingAString_thenRevceiveTheSameString() {
|
||||||
ReqResClient client = new ReqResClient();
|
ReqResClient client = new ReqResClient();
|
||||||
String string = "Hello RSocket";
|
String string = "Hello RSocket";
|
||||||
assertEquals(string, client.callBlocking(string));
|
assertEquals(string, client.callBlocking(string));
|
||||||
@ -37,20 +38,27 @@ public class RSocketIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFNFAndRequestStream() {
|
public void whenSendingStream_thenReceiveTheSameStream() {
|
||||||
// create the client that pushes data to the server and start sending
|
// create the client that pushes data to the server and start sending
|
||||||
FireNForgetClient fnfClient = new FireNForgetClient();
|
FireNForgetClient fnfClient = new FireNForgetClient();
|
||||||
// get the data that is used by the client
|
|
||||||
List<Float> data = fnfClient.getData();
|
|
||||||
|
|
||||||
// create a client to read a stream from the server and subscribe to events
|
// create a client to read a stream from the server and subscribe to events
|
||||||
ReqStreamClient streamClient = new ReqStreamClient();
|
ReqStreamClient streamClient = new ReqStreamClient();
|
||||||
|
|
||||||
|
// get the data that is used by the client
|
||||||
|
List<Float> data = fnfClient.getData();
|
||||||
|
// create a place to count the results
|
||||||
|
List<Float> dataReceived = new ArrayList<>();
|
||||||
|
|
||||||
// assert that the data received is the same as the data sent
|
// assert that the data received is the same as the data sent
|
||||||
Disposable subscription = streamClient.getDataStream()
|
Disposable subscription = streamClient.getDataStream()
|
||||||
.index()
|
.index()
|
||||||
.doOnNext(element -> assertEquals(data.get(element.getT1().intValue()), element.getT2()))
|
.subscribe(
|
||||||
.count()
|
tuple -> {
|
||||||
.subscribe(count -> assertEquals(data.size(), count.intValue()));
|
assertEquals("Wrong value", data.get(tuple.getT1().intValue()), tuple.getT2());
|
||||||
|
dataReceived.add(tuple.getT2());
|
||||||
|
},
|
||||||
|
err -> LOG.error(err.getMessage())
|
||||||
|
);
|
||||||
|
|
||||||
// start sending the data
|
// start sending the data
|
||||||
fnfClient.sendData();
|
fnfClient.sendData();
|
||||||
@ -59,10 +67,13 @@ public class RSocketIntegrationTest {
|
|||||||
try { Thread.sleep(500); } catch (Exception x) {}
|
try { Thread.sleep(500); } catch (Exception x) {}
|
||||||
subscription.dispose();
|
subscription.dispose();
|
||||||
fnfClient.dispose();
|
fnfClient.dispose();
|
||||||
|
|
||||||
|
// verify the item count
|
||||||
|
assertEquals("Wrong data count received", data.size(), dataReceived.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChannel() {
|
public void whenRunningChannelGame_thenLogTheResults() {
|
||||||
ChannelClient client = new ChannelClient();
|
ChannelClient client = new ChannelClient();
|
||||||
client.playGame();
|
client.playGame();
|
||||||
client.dispose();
|
client.dispose();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user