diff --git a/eureka-noweb/src/main/java/demo/StandaloneClientApplication.java b/eureka-noweb/src/main/java/demo/StandaloneClientApplication.java index a400b87..7719215 100644 --- a/eureka-noweb/src/main/java/demo/StandaloneClientApplication.java +++ b/eureka-noweb/src/main/java/demo/StandaloneClientApplication.java @@ -1,6 +1,5 @@ package demo; -import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; @@ -9,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; @@ -28,10 +26,7 @@ public class StandaloneClientApplication implements CommandLineRunner { @Override public void run(String... args) throws Exception { - List services = new ArrayList(); - for(ServiceInstance instance : client.getAllInstances()) { - services.add(instance.getServiceId()); - } + List services = client.getServices(); logger.info("Services: " + services ); } diff --git a/noweb/src/test/java/demo/DiscoveryNotWebApplicationTests.java b/noweb/src/test/java/demo/DiscoveryNotWebApplicationTests.java index 7563ebe..b94a4d8 100644 --- a/noweb/src/test/java/demo/DiscoveryNotWebApplicationTests.java +++ b/noweb/src/test/java/demo/DiscoveryNotWebApplicationTests.java @@ -2,7 +2,6 @@ package demo; import static org.junit.Assert.assertTrue; -import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; @@ -13,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.SpringApplicationConfiguration; -import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.noop.NoopDiscoveryClient; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -47,10 +45,7 @@ public class DiscoveryNotWebApplicationTests { @Override public void run(String... args) throws Exception { - List services = new ArrayList(); - for (ServiceInstance instance : client.getAllInstances()) { - services.add(instance.getServiceId()); - } + List services = client.getServices(); logger.info("Services: " + services); } } diff --git a/zuul-proxy-eureka/src/main/resources/application.properties b/zuul-proxy-eureka/src/main/resources/application.properties index 5f0bfd1..43525e0 100644 --- a/zuul-proxy-eureka/src/main/resources/application.properties +++ b/zuul-proxy-eureka/src/main/resources/application.properties @@ -1,2 +1,3 @@ +debug: spring.application.name: zuulproxy server.port: 9900 \ No newline at end of file diff --git a/zuul-proxy-eureka/src/test/java/demo/ZuulProxyEurekaApplicationTests.java b/zuul-proxy-eureka/src/test/java/demo/ZuulProxyEurekaApplicationTests.java index 867cc4e..3f7a750 100644 --- a/zuul-proxy-eureka/src/test/java/demo/ZuulProxyEurekaApplicationTests.java +++ b/zuul-proxy-eureka/src/test/java/demo/ZuulProxyEurekaApplicationTests.java @@ -8,11 +8,13 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.netflix.eureka.EurekaDiscoveryClient; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; import static org.junit.Assert.*; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = ZuulProxyEurekaApplication.class) +@WebAppConfiguration @DirtiesContext public class ZuulProxyEurekaApplicationTests {