|
|
@ -24,6 +24,8 @@ import org.springframework.boot.rsocket.messaging.RSocketStrategiesCustomizer;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
|
|
|
import org.springframework.core.codec.ByteArrayDecoder;
|
|
|
|
|
|
|
|
import org.springframework.core.codec.ByteArrayEncoder;
|
|
|
|
import org.springframework.core.codec.CharSequenceEncoder;
|
|
|
|
import org.springframework.core.codec.CharSequenceEncoder;
|
|
|
|
import org.springframework.core.codec.StringDecoder;
|
|
|
|
import org.springframework.core.codec.StringDecoder;
|
|
|
|
import org.springframework.http.codec.cbor.Jackson2CborDecoder;
|
|
|
|
import org.springframework.http.codec.cbor.Jackson2CborDecoder;
|
|
|
@ -51,16 +53,19 @@ public class RSocketStrategiesAutoConfigurationTests {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
assertThat(context).getBeans(RSocketStrategies.class).hasSize(1);
|
|
|
|
assertThat(context).getBeans(RSocketStrategies.class).hasSize(1);
|
|
|
|
RSocketStrategies strategies = context.getBean(RSocketStrategies.class);
|
|
|
|
RSocketStrategies strategies = context.getBean(RSocketStrategies.class);
|
|
|
|
assertThat(strategies.decoders()).hasSize(2);
|
|
|
|
assertThat(strategies.decoders()).hasSize(3);
|
|
|
|
assertThat(strategies.decoders().get(0))
|
|
|
|
assertThat(strategies.decoders().get(0))
|
|
|
|
.isInstanceOf(Jackson2CborDecoder.class);
|
|
|
|
.isInstanceOf(Jackson2CborDecoder.class);
|
|
|
|
assertThat(strategies.decoders().get(1))
|
|
|
|
assertThat(strategies.decoders().get(1))
|
|
|
|
.isInstanceOf(Jackson2JsonDecoder.class);
|
|
|
|
.isInstanceOf(Jackson2JsonDecoder.class);
|
|
|
|
assertThat(strategies.encoders()).hasSize(2);
|
|
|
|
assertThat(strategies.decoders().get(2)).isInstanceOf(StringDecoder.class);
|
|
|
|
|
|
|
|
assertThat(strategies.encoders()).hasSize(3);
|
|
|
|
assertThat(strategies.encoders().get(0))
|
|
|
|
assertThat(strategies.encoders().get(0))
|
|
|
|
.isInstanceOf(Jackson2CborEncoder.class);
|
|
|
|
.isInstanceOf(Jackson2CborEncoder.class);
|
|
|
|
assertThat(strategies.encoders().get(1))
|
|
|
|
assertThat(strategies.encoders().get(1))
|
|
|
|
.isInstanceOf(Jackson2JsonEncoder.class);
|
|
|
|
.isInstanceOf(Jackson2JsonEncoder.class);
|
|
|
|
|
|
|
|
assertThat(strategies.encoders().get(2))
|
|
|
|
|
|
|
|
.isInstanceOf(CharSequenceEncoder.class);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -80,10 +85,10 @@ public class RSocketStrategiesAutoConfigurationTests {
|
|
|
|
assertThat(context).getBeans(RSocketStrategies.class).hasSize(1);
|
|
|
|
assertThat(context).getBeans(RSocketStrategies.class).hasSize(1);
|
|
|
|
RSocketStrategies strategies = context
|
|
|
|
RSocketStrategies strategies = context
|
|
|
|
.getBean(RSocketStrategies.class);
|
|
|
|
.getBean(RSocketStrategies.class);
|
|
|
|
assertThat(strategies.decoders()).hasSize(3)
|
|
|
|
assertThat(strategies.decoders()).hasSize(4)
|
|
|
|
.hasAtLeastOneElementOfType(StringDecoder.class);
|
|
|
|
.hasAtLeastOneElementOfType(ByteArrayDecoder.class);
|
|
|
|
assertThat(strategies.encoders()).hasSize(3)
|
|
|
|
assertThat(strategies.encoders()).hasSize(4)
|
|
|
|
.hasAtLeastOneElementOfType(CharSequenceEncoder.class);
|
|
|
|
.hasAtLeastOneElementOfType(ByteArrayEncoder.class);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -119,8 +124,8 @@ public class RSocketStrategiesAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
public RSocketStrategiesCustomizer myCustomizer() {
|
|
|
|
public RSocketStrategiesCustomizer myCustomizer() {
|
|
|
|
return (strategies) -> strategies.encoder(CharSequenceEncoder.textPlainOnly())
|
|
|
|
return (strategies) -> strategies.encoder(new ByteArrayEncoder())
|
|
|
|
.decoder(StringDecoder.textPlainOnly());
|
|
|
|
.decoder(new ByteArrayDecoder());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|