ResponseEntity allows for setting non-standard status code

Issue: SPR-14205
This commit is contained in:
Juergen Hoeller
2016-04-26 23:05:21 +02:00
parent e5d52a96a7
commit d06188ed4d
7 changed files with 102 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -252,4 +252,22 @@ public class ResponseEntityTests {
assertThat(cacheControlHeader, Matchers.equalTo("no-store"));
}
@Test
public void statusCodeAsInt() {
Integer entity = new Integer(42);
ResponseEntity<Integer> responseEntity = ResponseEntity.status(200).body(entity);
assertEquals(200, responseEntity.getStatusCode().value());
assertEquals(entity, responseEntity.getBody());
}
@Test
public void customStatusCode() {
Integer entity = new Integer(42);
ResponseEntity<Integer> responseEntity = ResponseEntity.status(299).body(entity);
assertEquals(299, responseEntity.getStatusCodeValue());
assertEquals(entity, responseEntity.getBody());
}
}