"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "flow-server/src/test/java/com/vaadin/flow/internal/ResponseWriterTest.java" between
vaadin-flow-4.0.7.tar.gz and vaadin-flow-4.0.8.tar.gz

About: Vaadin flow is a Java framework binding Vaadin 17 web components to Java.

ResponseWriterTest.java  (vaadin-flow-4.0.7):ResponseWriterTest.java  (vaadin-flow-4.0.8)
skipping to change at line 489 skipping to change at line 489
// "File.js contents" // "File.js contents"
// ^0123456789ABCDEF^ // ^0123456789ABCDEF^
assertMultipartResponse(PATH_JS, Arrays.asList( assertMultipartResponse(PATH_JS, Arrays.asList(
new Pair<>(new String[] {"Content-Range: bytes 0-15/16"}, new Pair<>(new String[] {"Content-Range: bytes 0-15/16"},
"File.js contents".getBytes()), "File.js contents".getBytes()),
new Pair<>(new String[] {"Content-Range: bytes 1-4/16"}, new Pair<>(new String[] {"Content-Range: bytes 1-4/16"},
"ile.".getBytes()))); "ile.".getBytes())));
assertStatus(206); assertStatus(206);
} }
@Test
public void writeByteRangeMultiPartTooManyRequested() throws IOException {
makePathsAvailable(PATH_JS);
mockRequestHeaders(new Pair<>("Range", "bytes=0-0, 0-0, 1-1, 2-2, 3-3, 4
-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10, 11-11, 12-12, 13-13, 14-14, 15-15, 16-16"));
// "File.js contents"
// ^0123456789ABCDEF^
assertMultipartResponse(PATH_JS, Arrays.asList(
new Pair<>(new String[]{"Content-Range: bytes 0-0/16"}, "F".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 0-0/16"}, "F".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 1-1/16"}, "i".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 2-2/16"}, "l".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 3-3/16"}, "e".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 4-4/16"}, ".".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 5-5/16"}, "j".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 6-6/16"}, "s".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 7-7/16"}, " ".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 8-8/16"}, "c".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 9-9/16"}, "o".getB
ytes()),
new Pair<>(new String[]{"Content-Range: bytes 10-10/16"}, "n".ge
tBytes()),
new Pair<>(new String[]{"Content-Range: bytes 11-11/16"}, "t".ge
tBytes()),
new Pair<>(new String[]{"Content-Range: bytes 12-12/16"}, "e".ge
tBytes()),
new Pair<>(new String[]{"Content-Range: bytes 13-13/16"}, "n".ge
tBytes()),
new Pair<>(new String[]{"Content-Range: bytes 14-14/16"}, "t".ge
tBytes())));
assertStatus(206);
}
@Test
public void writeByteRangeMultiPartTooManyOverlappingRequested() throws IOEx
ception {
makePathsAvailable(PATH_JS);
mockRequestHeaders(new Pair<>("Range", "bytes=2-4, 0-4, 3-14"));
// "File.js contents"
// ^0123456789ABCDEF^
assertMultipartResponse(PATH_JS, Arrays.asList(
new Pair<>(new String[]{"Content-Range: bytes 2-4/16"}, "le.".ge
tBytes()),
new Pair<>(new String[]{"Content-Range: bytes 0-4/16"}, "File.".
getBytes())));
assertStatus(206);
}
private void assertResponse(byte[] expectedResponse) throws IOException { private void assertResponse(byte[] expectedResponse) throws IOException {
assertResponse(PATH_JS, expectedResponse); assertResponse(PATH_JS, expectedResponse);
} }
private void assertResponse(String path, byte[] expectedResponse) throws IOE xception { private void assertResponse(String path, byte[] expectedResponse) throws IOE xception {
CapturingServletOutputStream out = new CapturingServletOutputStream(); CapturingServletOutputStream out = new CapturingServletOutputStream();
Mockito.when(response.getOutputStream()).thenReturn(out); Mockito.when(response.getOutputStream()).thenReturn(out);
responseWriter.writeResponseContents(path, pathToUrl.get(path), responseWriter.writeResponseContents(path, pathToUrl.get(path),
request, response); request, response);
skipping to change at line 545 skipping to change at line 583
String.format("Headers:\n%s\ndid not contain:\n%s", String.format("Headers:\n%s\ndid not contain:\n%s",
actualHeaders, expectedHeader), actualHeaders, expectedHeader),
actualHeaders.contains(expectedHeader)); actualHeaders.contains(expectedHeader));
} }
byte[] expectedBytes = expected.getSecond(); byte[] expectedBytes = expected.getSecond();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
mps.readBodyData(outputStream); mps.readBodyData(outputStream);
byte[] bytes = outputStream.toByteArray(); byte[] bytes = outputStream.toByteArray();
Assert.assertArrayEquals(expectedBytes, bytes); Assert.assertArrayEquals(expectedBytes, bytes);
} }
// check that there are no excess parts
try {
mps.readHeaders();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
mps.readBodyData(outputStream);
Assert.assertTrue("excess bytes in multipart response",
outputStream.toByteArray().length == 0);
} catch (IOException ioe) {
// all is well, stream ended
}
} }
private void assertStatus(int status) { private void assertStatus(int status) {
Mockito.verify(response).setStatus(status); Mockito.verify(response).setStatus(status);
} }
private void makePathsAvailable(String... paths) private void makePathsAvailable(String... paths)
throws MalformedURLException { throws MalformedURLException {
for (String path : paths) { for (String path : paths) {
URL url = pathToUrl.get(path); URL url = pathToUrl.get(path);
 End of changes. 2 change blocks. 
0 lines changed or deleted 69 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)