use of io.rsocket.ConnectionSetupPayload in project spring-framework by spring-projects.
the class DefaultRSocketRequesterBuilderTests method mimeTypesCannotBeChangedAtRSocketConnectorLevel.
@Test
public void mimeTypesCannotBeChangedAtRSocketConnectorLevel() {
MimeType dataMimeType = MimeTypeUtils.APPLICATION_JSON;
MimeType metaMimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_ROUTING.getString());
RSocketRequester requester = RSocketRequester.builder().metadataMimeType(metaMimeType).dataMimeType(dataMimeType).rsocketConnector(connector -> {
connector.metadataMimeType("text/plain");
connector.dataMimeType("application/xml");
}).transport(this.transport);
ConnectionSetupPayload setupPayload = getConnectionSetupPayload(requester);
assertThat(setupPayload.dataMimeType()).isEqualTo(dataMimeType.toString());
assertThat(setupPayload.metadataMimeType()).isEqualTo(metaMimeType.toString());
assertThat(requester.dataMimeType()).isEqualTo(dataMimeType);
assertThat(requester.metadataMimeType()).isEqualTo(metaMimeType);
}
use of io.rsocket.ConnectionSetupPayload in project spring-framework by spring-projects.
the class DefaultRSocketRequesterBuilderTests method dataMimeTypeExplicitlySet.
@Test
public void dataMimeTypeExplicitlySet() {
RSocketRequester requester = RSocketRequester.builder().dataMimeType(MimeTypeUtils.APPLICATION_JSON).transport(this.transport);
ConnectionSetupPayload setupPayload = getConnectionSetupPayload(requester);
assertThat(setupPayload.dataMimeType()).isEqualTo("application/json");
assertThat(requester.dataMimeType()).isEqualTo(MimeTypeUtils.APPLICATION_JSON);
}
use of io.rsocket.ConnectionSetupPayload in project spring-framework by spring-projects.
the class DefaultRSocketRequesterBuilderTests method setupWithAsyncValues.
@Test
public void setupWithAsyncValues() {
Mono<String> asyncMeta1 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 1");
Mono<String> asyncMeta2 = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async Metadata 2");
Mono<String> data = Mono.delay(Duration.ofMillis(1)).map(aLong -> "Async data");
RSocketRequester requester = RSocketRequester.builder().dataMimeType(MimeTypeUtils.TEXT_PLAIN).setupRoute("toA").setupMetadata(asyncMeta1, new MimeType("text", "x.test.metadata1")).setupMetadata(asyncMeta2, new MimeType("text", "x.test.metadata2")).setupData(data).transport(this.transport);
ConnectionSetupPayload setupPayload = getConnectionSetupPayload(requester);
MimeType compositeMimeType = MimeTypeUtils.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_COMPOSITE_METADATA.getString());
DefaultMetadataExtractor extractor = new DefaultMetadataExtractor(StringDecoder.allMimeTypes());
extractor.metadataToExtract(new MimeType("text", "x.test.metadata1"), String.class, "asyncMeta1");
extractor.metadataToExtract(new MimeType("text", "x.test.metadata2"), String.class, "asyncMeta2");
Map<String, Object> metadataValues = extractor.extract(setupPayload, compositeMimeType);
assertThat(metadataValues.get("asyncMeta1")).isEqualTo("Async Metadata 1");
assertThat(metadataValues.get("asyncMeta2")).isEqualTo("Async Metadata 2");
assertThat(setupPayload.getDataUtf8()).isEqualTo("Async data");
}
use of io.rsocket.ConnectionSetupPayload in project spring-framework by spring-projects.
the class DefaultRSocketRequesterBuilderTests method setupRoute.
@Test
public void setupRoute() {
RSocketRequester requester = RSocketRequester.builder().dataMimeType(MimeTypeUtils.TEXT_PLAIN).metadataMimeType(MimeTypeUtils.TEXT_PLAIN).setupRoute("toA").setupData("My data").transport(this.transport);
ConnectionSetupPayload setupPayload = getConnectionSetupPayload(requester);
assertThat(setupPayload.getMetadataUtf8()).isEqualTo("toA");
assertThat(setupPayload.getDataUtf8()).isEqualTo("My data");
}
Aggregations