Upgrade to Mockito 2.11
Includes fixes for invalid exception declarations in Mockito-based unit tests. Also includes FreeMarker 2.3.27, Commons Pool 2.4.3, JSON-P 1.1.2. Issue: SPR-16157
This commit is contained in:
@@ -39,57 +39,57 @@ import static org.mockito.BDDMockito.*;
|
||||
public class HttpRangeTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidFirstPosition() throws Exception {
|
||||
public void invalidFirstPosition() {
|
||||
HttpRange.createByteRange(-1);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidLastLessThanFirst() throws Exception {
|
||||
public void invalidLastLessThanFirst() {
|
||||
HttpRange.createByteRange(10, 9);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidSuffixLength() throws Exception {
|
||||
public void invalidSuffixLength() {
|
||||
HttpRange.createSuffixRange(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byteRange() throws Exception {
|
||||
public void byteRange() {
|
||||
HttpRange range = HttpRange.createByteRange(0, 499);
|
||||
assertEquals(0, range.getRangeStart(1000));
|
||||
assertEquals(499, range.getRangeEnd(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byteRangeWithoutLastPosition() throws Exception {
|
||||
public void byteRangeWithoutLastPosition() {
|
||||
HttpRange range = HttpRange.createByteRange(9500);
|
||||
assertEquals(9500, range.getRangeStart(10000));
|
||||
assertEquals(9999, range.getRangeEnd(10000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void byteRangeOfZeroLength() throws Exception {
|
||||
public void byteRangeOfZeroLength() {
|
||||
HttpRange range = HttpRange.createByteRange(9500, 9500);
|
||||
assertEquals(9500, range.getRangeStart(10000));
|
||||
assertEquals(9500, range.getRangeEnd(10000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suffixRange() throws Exception {
|
||||
public void suffixRange() {
|
||||
HttpRange range = HttpRange.createSuffixRange(500);
|
||||
assertEquals(500, range.getRangeStart(1000));
|
||||
assertEquals(999, range.getRangeEnd(1000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suffixRangeShorterThanRepresentation() throws Exception {
|
||||
public void suffixRangeShorterThanRepresentation() {
|
||||
HttpRange range = HttpRange.createSuffixRange(500);
|
||||
assertEquals(0, range.getRangeStart(350));
|
||||
assertEquals(349, range.getRangeEnd(350));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseRanges() throws Exception {
|
||||
public void parseRanges() {
|
||||
List<HttpRange> ranges = HttpRange.parseRanges("bytes=0-0,500-,-1");
|
||||
assertEquals(3, ranges.size());
|
||||
assertEquals(0, ranges.get(0).getRangeStart(1000));
|
||||
@@ -137,8 +137,8 @@ public class HttpRangeTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void toResourceRegionExceptionLength() {
|
||||
ByteArrayResource resource = mock(ByteArrayResource.class);
|
||||
public void toResourceRegionExceptionLength() throws IOException {
|
||||
InputStreamResource resource = mock(InputStreamResource.class);
|
||||
given(resource.contentLength()).willThrow(IOException.class);
|
||||
HttpRange range = HttpRange.createByteRange(0, 9);
|
||||
range.toResourceRegion(resource);
|
||||
|
||||
@@ -167,7 +167,6 @@ public class HttpMessageConverterExtractorTests {
|
||||
given(converter.read(eq(type), eq(null), any(HttpInputMessage.class))).willReturn(expected);
|
||||
|
||||
Object result = extractor.extractData(response);
|
||||
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
|
||||
@@ -182,7 +181,8 @@ public class HttpMessageConverterExtractorTests {
|
||||
given(response.getRawStatusCode()).willReturn(HttpStatus.OK.value());
|
||||
given(response.getHeaders()).willReturn(responseHeaders);
|
||||
given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes()));
|
||||
given(converter.canRead(String.class, contentType)).willThrow(IOException.class);
|
||||
given(converter.canRead(String.class, contentType)).willReturn(true);
|
||||
given(converter.read(eq(String.class), any(HttpInputMessage.class))).willThrow(IOException.class);
|
||||
exception.expect(RestClientException.class);
|
||||
exception.expectMessage("Error while extracting response for type " +
|
||||
"[class java.lang.String] and content type [text/plain]");
|
||||
|
||||
Reference in New Issue
Block a user