Browse Source

Tests that if @EnableDiscoveryClient is used, but there is no implementation on the classpath, then fail

pull/15/head
Spencer Gibb 10 years ago
parent
commit
91150c7c83
  1. 38
      src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java

38
src/test/java/org/springframework/cloud/client/discovery/EnableDiscoveryClientMissingImplTests.java

@ -0,0 +1,38 @@ @@ -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 {
}
}
Loading…
Cancel
Save