Skip to content

Commit

Permalink
Merge branch '2.3.x' into 2.4.x
Browse files Browse the repository at this point in the history
Closes gh-25555
  • Loading branch information
wilkinsona committed Mar 9, 2021
2 parents fab45e4 + 84637ac commit ba5c57c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,6 +78,7 @@ RSocketWebSocketNettyRouteProvider rSocketWebsocketRouteProvider(RSocketProperti
}

@ConditionalOnProperty(prefix = "spring.rsocket.server", name = "port")
@ConditionalOnClass(ReactorResourceFactory.class)
@Configuration(proxyBeanMethods = false)
static class EmbeddedServerAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,17 +19,21 @@
import org.junit.jupiter.api.Test;

import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener;
import org.springframework.boot.logging.LogLevel;
import org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer;
import org.springframework.boot.rsocket.context.RSocketServerBootstrap;
import org.springframework.boot.rsocket.server.RSocketServerCustomizer;
import org.springframework.boot.rsocket.server.RSocketServerFactory;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.codec.CharSequenceEncoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.http.client.reactive.ReactorResourceFactory;
import org.springframework.messaging.rsocket.RSocketStrategies;
import org.springframework.messaging.rsocket.annotation.support.RSocketMessageHandler;
import org.springframework.util.unit.DataSize;
Expand Down Expand Up @@ -141,6 +145,14 @@ void shouldUseCustomNettyRouteProvider() {
.containsExactly("customNettyRouteProvider"));
}

@Test
void whenSpringWebIsNotPresentThenEmbeddedServerConfigurationBacksOff() {
contextRunner().withClassLoader(new FilteredClassLoader(ReactorResourceFactory.class))
.withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO))
.withPropertyValues("spring.rsocket.server.port=0")
.run((context) -> assertThat(context).doesNotHaveBean(RSocketServerFactory.class));
}

private ApplicationContextRunner contextRunner() {
return new ApplicationContextRunner().withUserConfiguration(BaseConfiguration.class)
.withConfiguration(AutoConfigurations.of(RSocketServerAutoConfiguration.class));
Expand Down

0 comments on commit ba5c57c

Please sign in to comment.