Tests that if @EnableDiscoveryClient is used, but there is no implementation on the classpath, then fail
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package org.springframework.cloud.client.discovery;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.NestedRuntimeException;
|
||||
|
||||
/**
|
||||
* Tests that if @EnableDiscoveryClient is used, but there is no implementation
|
||||
* on the classpath, then fail
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
public class EnableDiscoveryClientMissingImplTests {
|
||||
|
||||
@Test
|
||||
public void testContextFails() {
|
||||
try {
|
||||
new SpringApplicationBuilder()
|
||||
.sources(App.class)
|
||||
.web(false)
|
||||
.run(new String[0]);
|
||||
} catch (NestedRuntimeException e) {
|
||||
Throwable rootCause = e.getRootCause();
|
||||
assertTrue(rootCause instanceof IllegalStateException);
|
||||
assertTrue(rootCause.getMessage().contains("no implementations"));
|
||||
}
|
||||
}
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@Configuration
|
||||
@EnableDiscoveryClient
|
||||
//this will fail with @EnableDiscoveryClient and no implementation (nothing in spring.factories)
|
||||
public static class App {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user