Skip to content

Commit

Permalink
Updates to use new ServiceInstanceListSuppliers
Browse files Browse the repository at this point in the history
  • Loading branch information
spencergibb committed May 21, 2020
1 parent d7af241 commit 940d69c
Showing 1 changed file with 14 additions and 14 deletions.
Expand Up @@ -35,7 +35,7 @@
import org.springframework.cloud.loadbalancer.core.ReactorLoadBalancer;
import org.springframework.cloud.loadbalancer.core.RoundRobinLoadBalancer;
import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory;
import org.springframework.cloud.loadbalancer.support.ServiceInstanceSuppliers;
import org.springframework.cloud.loadbalancer.support.ServiceInstanceListSuppliers;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
Expand Down Expand Up @@ -121,10 +121,11 @@ public void shouldFilter() {
ServiceInstance serviceInstance = new DefaultServiceInstance("myservice1",
"myservice", "localhost", 8080, true);

RoundRobinLoadBalancer loadBalancer = new RoundRobinLoadBalancer(
ServiceInstanceListSuppliers.toProvider("myservice", serviceInstance),
"myservice", -1);
when(clientFactory.getInstance("myservice", ReactorLoadBalancer.class,
ServiceInstance.class)).thenReturn(new RoundRobinLoadBalancer("myservice",
ServiceInstanceSuppliers.toProvider("myservice", serviceInstance),
-1));
ServiceInstance.class)).thenReturn(loadBalancer);

when(chain.filter(exchange)).thenReturn(Mono.empty());

Expand Down Expand Up @@ -246,10 +247,10 @@ public void shouldNotFilterWhenGatewaySchemePrefixAttrIsNotLb() {
public void shouldThrow4O4ExceptionWhenNoServiceInstanceIsFound() {
URI uri = UriComponentsBuilder.fromUriString("lb://service1").build().toUri();
exchange.getAttributes().put(GATEWAY_REQUEST_URL_ATTR, uri);
RoundRobinLoadBalancer loadBalancer = new RoundRobinLoadBalancer(
ServiceInstanceListSuppliers.toProvider("service1"), "service1", -1);
when(clientFactory.getInstance("service1", ReactorLoadBalancer.class,
ServiceInstance.class))
.thenReturn(new RoundRobinLoadBalancer("service1",
ServiceInstanceSuppliers.toProvider("service1"), -1));
ServiceInstance.class)).thenReturn(loadBalancer);
properties.setUse404(true);
ReactiveLoadBalancerClientFilter filter = new ReactiveLoadBalancerClientFilter(
clientFactory, properties);
Expand All @@ -273,14 +274,13 @@ private ServerWebExchange testFilter(ServerWebExchange exchange, URI uri) {
.forClass(ServerWebExchange.class);
when(chain.filter(captor.capture())).thenReturn(Mono.empty());

RoundRobinLoadBalancer loadBalancer = new RoundRobinLoadBalancer(
ServiceInstanceListSuppliers.toProvider("service1",
new DefaultServiceInstance("service1_1", "service1",
"service1-host1", 8081, false)),
"service1", -1);
when(clientFactory.getInstance("service1", ReactorLoadBalancer.class,
ServiceInstance.class))
.thenReturn(new RoundRobinLoadBalancer("service1",
ServiceInstanceSuppliers.toProvider("service1",
new DefaultServiceInstance("service1_1",
"service1", "service1-host1", 8081,
false)),
-1));
ServiceInstance.class)).thenReturn(loadBalancer);

ReactiveLoadBalancerClientFilter filter = new ReactiveLoadBalancerClientFilter(
clientFactory, properties);
Expand Down

0 comments on commit 940d69c

Please sign in to comment.