Skip to content

Commit 40fc472

Browse files
committed
Polish ExceptionHandlerTests
1 parent 7a31885 commit 40fc472

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/ExceptionHandlerTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,30 +30,31 @@
3030
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
3131

3232
/**
33-
* Exception handling via {@code @ExceptionHandler} method.
33+
* Exception handling via {@code @ExceptionHandler} methods.
3434
*
3535
* @author Rossen Stoyanchev
36+
* @author Sam Brannen
3637
*/
37-
public class ExceptionHandlerTests {
38+
class ExceptionHandlerTests {
3839

3940
@Test
40-
public void testExceptionHandlerMethod() throws Exception {
41+
void localExceptionHandlerMethod() throws Exception {
4142
standaloneSetup(new PersonController()).build()
4243
.perform(get("/person/Clyde"))
4344
.andExpect(status().isOk())
4445
.andExpect(forwardedUrl("errorView"));
4546
}
4647

4748
@Test
48-
public void testGlobalExceptionHandlerMethod() throws Exception {
49+
void globalExceptionHandlerMethod() throws Exception {
4950
standaloneSetup(new PersonController()).setControllerAdvice(new GlobalExceptionHandler()).build()
5051
.perform(get("/person/Bonnie"))
5152
.andExpect(status().isOk())
5253
.andExpect(forwardedUrl("globalErrorView"));
5354
}
5455

5556
@Test
56-
public void testGlobalExceptionHandlerMethodUsingClassArgument() throws Exception {
57+
void globalExceptionHandlerMethodUsingClassArgument() throws Exception {
5758
standaloneSetup(PersonController.class).setControllerAdvice(GlobalExceptionHandler.class).build()
5859
.perform(get("/person/Bonnie"))
5960
.andExpect(status().isOk())
@@ -65,7 +66,7 @@ public void testGlobalExceptionHandlerMethodUsingClassArgument() throws Exceptio
6566
private static class PersonController {
6667

6768
@GetMapping("/person/{name}")
68-
public String show(@PathVariable String name) {
69+
String show(@PathVariable String name) {
6970
if (name.equals("Clyde")) {
7071
throw new IllegalArgumentException("simulated exception");
7172
}
@@ -76,7 +77,7 @@ else if (name.equals("Bonnie")) {
7677
}
7778

7879
@ExceptionHandler
79-
public String handleException(IllegalArgumentException exception) {
80+
String handleException(IllegalArgumentException exception) {
8081
return "errorView";
8182
}
8283
}
@@ -86,10 +87,9 @@ public String handleException(IllegalArgumentException exception) {
8687
private static class GlobalExceptionHandler {
8788

8889
@ExceptionHandler
89-
public String handleException(IllegalStateException exception) {
90+
String handleException(IllegalStateException exception) {
9091
return "globalErrorView";
9192
}
92-
9393
}
9494

9595
}

0 commit comments

Comments
 (0)