11/*
2- * Copyright 2012-2020 the original author or authors.
2+ * Copyright 2012-2021 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2727import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
2828import org .springframework .boot .test .context .SpringBootTest ;
2929import org .springframework .cloud .client .ServiceInstance ;
30- import org .springframework .cloud .client .discovery .simple .SimpleDiscoveryClient ;
3130import org .springframework .context .annotation .Configuration ;
3231import org .springframework .test .context .junit4 .SpringRunner ;
3332
3433import static org .assertj .core .api .BDDAssertions .then ;
3534
3635/**
37- * Tests for mapping properties to instances in {@link SimpleDiscoveryClient }
36+ * Tests for mapping properties to instances in {@link SimpleReactiveDiscoveryClient }
3837 *
3938 * @author Daniel Gerber
4039 */
41-
4240@ RunWith (SpringRunner .class )
4341@ SpringBootTest (properties = { "spring.application.name=service0" ,
4442 "spring.cloud.discovery.client.simple.instances.service1[0].uri=http://s11:8080" ,
@@ -55,25 +53,25 @@ public class SimpleReactiveDiscoveryClientPropertiesMappingTests {
5553
5654 @ Test
5755 public void propsShouldGetCleanlyMapped () {
58- then (this . props .getInstances ().size ()).isEqualTo (2 );
59- then (this . props .getInstances ().get ("service1" ).size ()).isEqualTo (2 );
60- then (this . props .getInstances ().get ("service1" ).get (0 ).getHost ()).isEqualTo ("s11" );
61- then (this . props .getInstances ().get ("service1" ).get (0 ).getPort ()).isEqualTo (8080 );
62- then (this . props .getInstances ().get ("service1" ).get (0 ).getUri ()).isEqualTo (URI .create ("http://s11:8080" ));
63- then (this . props .getInstances ().get ("service1" ).get (0 ).isSecure ()).isEqualTo (false );
64-
65- then (this . props .getInstances ().get ("service2" ).size ()).isEqualTo (2 );
66- then (this . props .getInstances ().get ("service2" ).get (0 ).getHost ()).isEqualTo ("s21" );
67- then (this . props .getInstances ().get ("service2" ).get (0 ).getPort ()).isEqualTo (8080 );
68- then (this . props .getInstances ().get ("service2" ).get (0 ).getUri ()).isEqualTo (URI .create ("https://s21:8080" ));
69- then (this . props .getInstances ().get ("service2" ).get (0 ).isSecure ()).isEqualTo (true );
56+ then (props .getInstances ().size ()).isEqualTo (2 );
57+ then (props .getInstances ().get ("service1" ).size ()).isEqualTo (2 );
58+ then (props .getInstances ().get ("service1" ).get (0 ).getHost ()).isEqualTo ("s11" );
59+ then (props .getInstances ().get ("service1" ).get (0 ).getPort ()).isEqualTo (8080 );
60+ then (props .getInstances ().get ("service1" ).get (0 ).getUri ()).isEqualTo (URI .create ("http://s11:8080" ));
61+ then (props .getInstances ().get ("service1" ).get (0 ).isSecure ()).isEqualTo (false );
62+
63+ then (props .getInstances ().get ("service2" ).size ()).isEqualTo (2 );
64+ then (props .getInstances ().get ("service2" ).get (0 ).getHost ()).isEqualTo ("s21" );
65+ then (props .getInstances ().get ("service2" ).get (0 ).getPort ()).isEqualTo (8080 );
66+ then (props .getInstances ().get ("service2" ).get (0 ).getUri ()).isEqualTo (URI .create ("https://s21:8080" ));
67+ then (props .getInstances ().get ("service2" ).get (0 ).isSecure ()).isEqualTo (true );
7068 }
7169
7270 @ Test
7371 public void testDiscoveryClientShouldResolveSimpleValues () {
74- then (this . discoveryClient .description ()).isEqualTo ("Simple Reactive Discovery Client" );
72+ then (discoveryClient .description ()).isEqualTo ("Simple Reactive Discovery Client" );
7573
76- Flux <ServiceInstance > services = this . discoveryClient .getInstances ("service1" );
74+ Flux <ServiceInstance > services = discoveryClient .getInstances ("service1" );
7775 StepVerifier .create (services )
7876 .expectNextMatches (inst -> inst .getHost ().equals ("s11" ) && inst .getPort () == 8080
7977 && inst .getUri ().toString ().equals ("http://s11:8080" ) && !inst .isSecure ()
@@ -86,9 +84,9 @@ public void testDiscoveryClientShouldResolveSimpleValues() {
8684
8785 @ Test
8886 public void testGetANonExistentServiceShouldReturnAnEmptyList () {
89- then (this . discoveryClient .description ()).isEqualTo ("Simple Reactive Discovery Client" );
87+ then (discoveryClient .description ()).isEqualTo ("Simple Reactive Discovery Client" );
9088
91- Flux <ServiceInstance > services = this . discoveryClient .getInstances ("nonexistent" );
89+ Flux <ServiceInstance > services = discoveryClient .getInstances ("nonexistent" );
9290
9391 StepVerifier .create (services ).expectNextCount (0 ).expectComplete ().verify ();
9492 }
0 commit comments