diff --git a/turbine/pom.xml b/turbine/pom.xml index 83a2df4..29d8450 100644 --- a/turbine/pom.xml +++ b/turbine/pom.xml @@ -41,6 +41,16 @@ org.springframework.cloud spring-cloud-starter-turbine + + org.springframework.cloud + spring-cloud-starter-hystrix + test + + + org.springframework.cloud + spring-cloud-starter-eureka-server + test + org.springframework.boot spring-boot-starter-test diff --git a/turbine/src/main/resources/application.properties b/turbine/src/main/resources/application.properties index e884298..499f703 100644 --- a/turbine/src/main/resources/application.properties +++ b/turbine/src/main/resources/application.properties @@ -1,3 +1,3 @@ server.port: 8989 spring.application.name: turbine -eureka.client.serviceUrl.defaultZone: http://user:password@localhost:8761/eureka/ \ No newline at end of file +turbine.appConfig: simple \ No newline at end of file diff --git a/turbine/src/test/java/apps/EurekaServerApplication.java b/turbine/src/test/java/apps/EurekaServerApplication.java new file mode 100644 index 0000000..1983ade --- /dev/null +++ b/turbine/src/test/java/apps/EurekaServerApplication.java @@ -0,0 +1,19 @@ +package apps; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableAutoConfiguration +@EnableEurekaServer +public class EurekaServerApplication { + + public static void main(String[] args) { + new SpringApplicationBuilder(EurekaServerApplication.class).properties( + "spring.config.name:eureka", "logging.level.com.netflix.discovery:OFF") + .run(args); + } + +} diff --git a/turbine/src/test/java/apps/SimpleApplication.java b/turbine/src/test/java/apps/SimpleApplication.java new file mode 100644 index 0000000..9a62bc1 --- /dev/null +++ b/turbine/src/test/java/apps/SimpleApplication.java @@ -0,0 +1,75 @@ +/* + * Copyright 2014-2015 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package apps; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; + +@Configuration +@EnableAutoConfiguration +@EnableDiscoveryClient +@EnableCircuitBreaker +@RestController +public class SimpleApplication { + + @Autowired + private HelloService service; + + @RequestMapping("/") + public String hello() { + return service.hello(); + } + + @RequestMapping("/fail") + public String fail() { + return service.fail(); + } + + public static void main(String[] args) { + new SpringApplicationBuilder(SimpleApplication.class).properties( + "spring.config.name:simple").run(args); + } + + @Service + public static class HelloService { + + @HystrixCommand(fallbackMethod="fallback") + public String hello() { + return "Hello World"; + } + + @HystrixCommand(fallbackMethod="fallback") + public String fail() { + throw new RuntimeException("Planned"); + } + + public String fallback() { + return "Fallback"; + } + + } + +} diff --git a/turbine/src/test/java/demo/TurbineApplicationTests.java b/turbine/src/test/java/demo/TurbineApplicationTests.java index f865844..4aedc96 100644 --- a/turbine/src/test/java/demo/TurbineApplicationTests.java +++ b/turbine/src/test/java/demo/TurbineApplicationTests.java @@ -27,4 +27,5 @@ public class TurbineApplicationTests { public void discoveryClientIsEureka() { assertTrue("discoveryClient is wrong type", discoveryClient instanceof EurekaDiscoveryClient); } + } diff --git a/turbine/src/test/resources/eureka.properties b/turbine/src/test/resources/eureka.properties new file mode 100644 index 0000000..a0e3d7f --- /dev/null +++ b/turbine/src/test/resources/eureka.properties @@ -0,0 +1,4 @@ +server.port: 8761 +spring.application.name: eureka +eureka.client.registerWithEureka=false +eureka.client.fetchRegistry=false \ No newline at end of file diff --git a/turbine/src/test/resources/simple.properties b/turbine/src/test/resources/simple.properties new file mode 100644 index 0000000..ec7a5fc --- /dev/null +++ b/turbine/src/test/resources/simple.properties @@ -0,0 +1,2 @@ +server.port: 8080 +spring.application.name: simple