Provide informative reason when rejecting request with invalid level

Previously, bad request with no reason was included in the response.
This commit introduces the reason when invalid log level is sent in the
request.

Fixes gh-10588
This commit is contained in:
Eddú Meléndez
2017-10-10 18:52:00 -05:00
committed by Andy Wilkinson
parent 5acd6c40eb
commit 9e5a1b32c8
2 changed files with 19 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -174,7 +175,8 @@ public class LoggersMvcEndpointTests {
public void setLoggerWithWrongLogLevel() throws Exception {
this.mvc.perform(post("/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
.content("{\"configuredLevel\":\"other\"}"))
.andExpect(status().is4xxClientError());
.andExpect(status().is4xxClientError())
.andExpect(status().reason(is("No such log level")));
verifyZeroInteractions(this.loggingSystem);
}