Add eureka and lient apps to turbine tests
This commit is contained in:
@@ -41,6 +41,16 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-turbine</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-hystrix</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka-server</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
server.port: 8989
|
||||
spring.application.name: turbine
|
||||
eureka.client.serviceUrl.defaultZone: http://user:password@localhost:8761/eureka/
|
||||
turbine.appConfig: simple
|
||||
19
turbine/src/test/java/apps/EurekaServerApplication.java
Normal file
19
turbine/src/test/java/apps/EurekaServerApplication.java
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
75
turbine/src/test/java/apps/SimpleApplication.java
Normal file
75
turbine/src/test/java/apps/SimpleApplication.java
Normal file
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,4 +27,5 @@ public class TurbineApplicationTests {
|
||||
public void discoveryClientIsEureka() {
|
||||
assertTrue("discoveryClient is wrong type", discoveryClient instanceof EurekaDiscoveryClient);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
4
turbine/src/test/resources/eureka.properties
Normal file
4
turbine/src/test/resources/eureka.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
server.port: 8761
|
||||
spring.application.name: eureka
|
||||
eureka.client.registerWithEureka=false
|
||||
eureka.client.fetchRegistry=false
|
||||
2
turbine/src/test/resources/simple.properties
Normal file
2
turbine/src/test/resources/simple.properties
Normal file
@@ -0,0 +1,2 @@
|
||||
server.port: 8080
|
||||
spring.application.name: simple
|
||||
Reference in New Issue
Block a user