1
1
/*
2
- * Copyright 2012-2020 the original author or authors.
2
+ * Copyright 2012-2021 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
27
27
import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
28
28
import org .springframework .boot .test .context .SpringBootTest ;
29
29
import org .springframework .cloud .client .ServiceInstance ;
30
- import org .springframework .cloud .client .discovery .simple .SimpleDiscoveryClient ;
31
30
import org .springframework .context .annotation .Configuration ;
32
31
import org .springframework .test .context .junit4 .SpringRunner ;
33
32
34
33
import static org .assertj .core .api .BDDAssertions .then ;
35
34
36
35
/**
37
- * Tests for mapping properties to instances in {@link SimpleDiscoveryClient }
36
+ * Tests for mapping properties to instances in {@link SimpleReactiveDiscoveryClient }
38
37
*
39
38
* @author Daniel Gerber
40
39
*/
41
-
42
40
@ RunWith (SpringRunner .class )
43
41
@ SpringBootTest (properties = { "spring.application.name=service0" ,
44
42
"spring.cloud.discovery.client.simple.instances.service1[0].uri=http://s11:8080" ,
@@ -55,25 +53,25 @@ public class SimpleReactiveDiscoveryClientPropertiesMappingTests {
55
53
56
54
@ Test
57
55
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 );
70
68
}
71
69
72
70
@ Test
73
71
public void testDiscoveryClientShouldResolveSimpleValues () {
74
- then (this . discoveryClient .description ()).isEqualTo ("Simple Reactive Discovery Client" );
72
+ then (discoveryClient .description ()).isEqualTo ("Simple Reactive Discovery Client" );
75
73
76
- Flux <ServiceInstance > services = this . discoveryClient .getInstances ("service1" );
74
+ Flux <ServiceInstance > services = discoveryClient .getInstances ("service1" );
77
75
StepVerifier .create (services )
78
76
.expectNextMatches (inst -> inst .getHost ().equals ("s11" ) && inst .getPort () == 8080
79
77
&& inst .getUri ().toString ().equals ("http://s11:8080" ) && !inst .isSecure ()
@@ -86,9 +84,9 @@ public void testDiscoveryClientShouldResolveSimpleValues() {
86
84
87
85
@ Test
88
86
public void testGetANonExistentServiceShouldReturnAnEmptyList () {
89
- then (this . discoveryClient .description ()).isEqualTo ("Simple Reactive Discovery Client" );
87
+ then (discoveryClient .description ()).isEqualTo ("Simple Reactive Discovery Client" );
90
88
91
- Flux <ServiceInstance > services = this . discoveryClient .getInstances ("nonexistent" );
89
+ Flux <ServiceInstance > services = discoveryClient .getInstances ("nonexistent" );
92
90
93
91
StepVerifier .create (services ).expectNextCount (0 ).expectComplete ().verify ();
94
92
}
0 commit comments