@ -33,6 +33,7 @@ import org.springframework.cloud.loadbalancer.core.HealthCheckServiceInstanceLis
@@ -33,6 +33,7 @@ import org.springframework.cloud.loadbalancer.core.HealthCheckServiceInstanceLis
import org.springframework.cloud.loadbalancer.core.RequestBasedStickySessionServiceInstanceListSupplier ;
import org.springframework.cloud.loadbalancer.core.RetryAwareServiceInstanceListSupplier ;
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier ;
import org.springframework.cloud.loadbalancer.core.WeightedServiceInstanceListSupplier ;
import org.springframework.cloud.loadbalancer.core.ZonePreferenceServiceInstanceListSupplier ;
import org.springframework.context.annotation.Bean ;
import org.springframework.context.annotation.Configuration ;
@ -46,6 +47,7 @@ import static org.assertj.core.api.BDDAssertions.then;
@@ -46,6 +47,7 @@ import static org.assertj.core.api.BDDAssertions.then;
* Tests for { @link LoadBalancerClientConfiguration } .
*
* @author Olga Maciaszek - Sharma
* @author Zhuozhi Ji
* /
class LoadBalancerClientConfigurationTests {
@ -113,6 +115,18 @@ class LoadBalancerClientConfigurationTests {
@@ -113,6 +115,18 @@ class LoadBalancerClientConfigurationTests {
} ) ;
}
@Test
void shouldInstantiateWeightedServiceInstanceListSupplier ( ) {
reactiveDiscoveryClientRunner . withUserConfiguration ( TestConfig . class )
. withPropertyValues ( "spring.cloud.loadbalancer.configurations=weighted" ) . run ( context - > {
ServiceInstanceListSupplier supplier = context . getBean ( ServiceInstanceListSupplier . class ) ;
then ( supplier ) . isInstanceOf ( WeightedServiceInstanceListSupplier . class ) ;
ServiceInstanceListSupplier delegate = ( ( DelegatingServiceInstanceListSupplier ) supplier )
. getDelegate ( ) ;
then ( delegate ) . isInstanceOf ( DiscoveryClientServiceInstanceListSupplier . class ) ;
} ) ;
}
@Test
void shouldInstantiateRequestBasedStickySessionServiceInstanceListSupplierTests ( ) {
reactiveDiscoveryClientRunner . withUserConfiguration ( TestConfig . class )
@ -182,6 +196,17 @@ class LoadBalancerClientConfigurationTests {
@@ -182,6 +196,17 @@ class LoadBalancerClientConfigurationTests {
} ) ;
}
@Test
void shouldInstantiateBlockingWeightedServiceInstanceListSupplier ( ) {
blockingDiscoveryClientRunner . withUserConfiguration ( RestTemplateTestConfig . class )
. withPropertyValues ( "spring.cloud.loadbalancer.configurations=weighted" ) . run ( context - > {
ServiceInstanceListSupplier supplier = context . getBean ( ServiceInstanceListSupplier . class ) ;
then ( supplier ) . isInstanceOf ( WeightedServiceInstanceListSupplier . class ) ;
then ( ( ( DelegatingServiceInstanceListSupplier ) supplier ) . getDelegate ( ) )
. isInstanceOf ( DiscoveryClientServiceInstanceListSupplier . class ) ;
} ) ;
}
@Configuration
protected static class TestConfig {