mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
code format
This commit is contained in:
parent
46c888f878
commit
ec98a2db01
@ -25,25 +25,26 @@ public class ProviderApplication {
|
|||||||
@RestController
|
@RestController
|
||||||
class EchoController {
|
class EchoController {
|
||||||
|
|
||||||
@RequestMapping(value = "/", method = RequestMethod.GET)
|
@RequestMapping(value = "/", method = RequestMethod.GET)
|
||||||
public ResponseEntity index() {
|
public ResponseEntity index() {
|
||||||
return new ResponseEntity("index error", HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity("index error", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/test", method = RequestMethod.GET)
|
@RequestMapping(value = "/test", method = RequestMethod.GET)
|
||||||
public ResponseEntity test() {
|
public ResponseEntity test() {
|
||||||
return new ResponseEntity("error", HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity("error", HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/sleep", method = RequestMethod.GET)
|
@RequestMapping(value = "/sleep", method = RequestMethod.GET)
|
||||||
public String sleep() {
|
public String sleep() {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000L);
|
Thread.sleep(1000L);
|
||||||
} catch (InterruptedException e) {
|
}
|
||||||
e.printStackTrace();
|
catch (InterruptedException e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
return "ok";
|
}
|
||||||
}
|
return "ok";
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)
|
@RequestMapping(value = "/echo/{string}", method = RequestMethod.GET)
|
||||||
public String echo(@PathVariable String string) {
|
public String echo(@PathVariable String string) {
|
||||||
|
@ -106,9 +106,9 @@ public class SentinelAutoConfigurationTests {
|
|||||||
@LocalServerPort
|
@LocalServerPort
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
private String flowUrl = "http://localhost:" + port + "/flow";
|
private String flowUrl = "http://localhost:" + port + "/flow";
|
||||||
|
|
||||||
private String degradeUrl = "http://localhost:" + port + "/degrade";
|
private String degradeUrl = "http://localhost:" + port + "/degrade";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@ -249,14 +249,15 @@ public class SentinelAutoConfigurationTests {
|
|||||||
restTemplate.getInterceptors().size());
|
restTemplate.getInterceptors().size());
|
||||||
assertEquals("RestTemplateWithBlockClass interceptors size was wrong", 1,
|
assertEquals("RestTemplateWithBlockClass interceptors size was wrong", 1,
|
||||||
restTemplateWithBlockClass.getInterceptors().size());
|
restTemplateWithBlockClass.getInterceptors().size());
|
||||||
ResponseEntity responseEntityBlock = restTemplateWithBlockClass.getForEntity(flowUrl,
|
ResponseEntity responseEntityBlock = restTemplateWithBlockClass
|
||||||
String.class);
|
.getForEntity(flowUrl, String.class);
|
||||||
assertEquals("RestTemplateWithBlockClass Sentinel Block Message was wrong",
|
assertEquals("RestTemplateWithBlockClass Sentinel Block Message was wrong",
|
||||||
"Oops", responseEntityBlock.getBody());
|
"Oops", responseEntityBlock.getBody());
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"RestTemplateWithBlockClass Sentinel Block Http Status Code was wrong",
|
"RestTemplateWithBlockClass Sentinel Block Http Status Code was wrong",
|
||||||
HttpStatus.OK, responseEntityBlock.getStatusCode());
|
HttpStatus.OK, responseEntityBlock.getStatusCode());
|
||||||
ResponseEntity responseEntityRaw = restTemplate.getForEntity(flowUrl, String.class);
|
ResponseEntity responseEntityRaw = restTemplate.getForEntity(flowUrl,
|
||||||
|
String.class);
|
||||||
assertEquals("RestTemplate Sentinel Block Message was wrong",
|
assertEquals("RestTemplate Sentinel Block Message was wrong",
|
||||||
"RestTemplate request block by sentinel", responseEntityRaw.getBody());
|
"RestTemplate request block by sentinel", responseEntityRaw.getBody());
|
||||||
assertEquals("RestTemplate Sentinel Block Http Status Code was wrong",
|
assertEquals("RestTemplate Sentinel Block Http Status Code was wrong",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user