|
| 1 | +package org.springframework.cloud.client.discovery; |
| 2 | + |
| 3 | +import org.junit.Test; |
| 4 | +import org.junit.runner.RunWith; |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; |
| 6 | +import org.springframework.beans.factory.annotation.Value; |
| 7 | +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
| 8 | +import org.springframework.boot.test.context.SpringBootTest; |
| 9 | +import org.springframework.cloud.client.serviceregistry.AutoServiceRegistration; |
| 10 | +import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration; |
| 11 | +import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties; |
| 12 | +import org.springframework.context.annotation.Configuration; |
| 13 | +import org.springframework.test.context.junit4.SpringRunner; |
| 14 | + |
| 15 | +import static org.junit.Assert.assertFalse; |
| 16 | +import static org.junit.Assert.assertNull; |
| 17 | + |
| 18 | +/** |
| 19 | + * @author Ryan Baxter |
| 20 | + */ |
| 21 | +@RunWith(SpringRunner.class) |
| 22 | +@SpringBootTest(properties = {"spring.cloud.service-registry.auto-registration.enabled: false"}) |
| 23 | +public class AutoRegisterPropertyFalseTests { |
| 24 | + @Autowired(required = false) |
| 25 | + AutoServiceRegistrationAutoConfiguration autoConfiguration; |
| 26 | + |
| 27 | + @Autowired(required = false) |
| 28 | + AutoServiceRegistration autoServiceRegistration; |
| 29 | + |
| 30 | + @Autowired(required = false) |
| 31 | + AutoServiceRegistrationProperties autoServiceRegistrationProperties; |
| 32 | + |
| 33 | + @Value("${spring.cloud.service-registry.auto-registration.enabled}") |
| 34 | + Boolean autoRegisterProperty; |
| 35 | + |
| 36 | + @Test |
| 37 | + public void veryifyBeans() { |
| 38 | + assertNull(autoConfiguration); |
| 39 | + assertNull(autoServiceRegistration); |
| 40 | + assertNull(autoServiceRegistrationProperties); |
| 41 | + assertFalse(autoRegisterProperty); |
| 42 | + } |
| 43 | + |
| 44 | + |
| 45 | + @EnableAutoConfiguration |
| 46 | + @Configuration |
| 47 | + public static class App { |
| 48 | + } |
| 49 | +} |
0 commit comments