Add the protocol-comparison module
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.ankurm.protocols;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.messaging.rsocket.RSocketStrategies;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* What Boot actually configures for RSocket, printed rather than quoted.
|
||||
*
|
||||
* <p>A bare {@code RSocketStrategies.create()} carries no JSON and no CBOR at all — only
|
||||
* the string and buffer codecs. Everything interesting comes from Boot's
|
||||
* {@code RSocketStrategiesAutoConfiguration}, which is also where the default data mime type is
|
||||
* decided, and it is not the one most people assume.
|
||||
*/
|
||||
@SpringBootTest(properties = {"spring.rsocket.server.port=7005", "spring.grpc.server.port=9095"})
|
||||
class RSocketDefaultsTest {
|
||||
|
||||
@Autowired
|
||||
RSocketStrategies strategies;
|
||||
|
||||
@Test
|
||||
void bootConfiguredCodecs() {
|
||||
var encoders = strategies.encoders().stream().map(e -> e.getClass().getSimpleName()).toList();
|
||||
var decoders = strategies.decoders().stream().map(d -> d.getClass().getSimpleName()).toList();
|
||||
|
||||
System.out.println("=== Boot-configured RSocketStrategies ===");
|
||||
System.out.println("encoders : " + encoders);
|
||||
System.out.println("decoders : " + decoders);
|
||||
System.out.println("bare RSocketStrategies.create() encoders : "
|
||||
+ RSocketStrategies.create().encoders().stream()
|
||||
.map(e -> e.getClass().getSimpleName()).toList());
|
||||
|
||||
assertThat(encoders).isNotEmpty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user