1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-18 04:01:42 +00:00

Closes #208: display file content + fix filename encoding

This commit is contained in:
Benjamin Gamard
2018-03-23 16:41:02 +01:00
parent 55a4bb7621
commit be1c2a7b90
10 changed files with 53 additions and 12 deletions

View File

@@ -580,6 +580,16 @@ public class TestDocumentResource extends BaseJerseyTest {
Assert.assertTrue(fileBytes.length > 0); // Images rendered from PDF differ in size from OS to OS due to font issues
Assert.assertEquals(MimeType.IMAGE_JPEG, MimeTypeUtil.guessMimeType(fileBytes, null));
// Get the content data
response = target().path("/file/" + file1Id + "/data")
.queryParam("size", "content")
.request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, documentPlainToken)
.get();
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
is = (InputStream) response.getEntity();
Assert.assertTrue(new String(ByteStreams.toByteArray(is)).contains("love"));
// Export a document in PDF format
response = target().path("/document/" + document1Id + "/pdf")
.queryParam("margin", "10")

View File

@@ -106,6 +106,14 @@ public class TestFileResource extends BaseJerseyTest {
Assert.assertEquals(MimeType.IMAGE_JPEG, MimeTypeUtil.guessMimeType(fileBytes, null));
Assert.assertTrue(fileBytes.length > 0);
// Get the content data
response = target().path("/file/" + file1Id + "/data")
.queryParam("size", "content")
.request()
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, file1Token)
.get();
Assert.assertEquals(Status.OK, Status.fromStatusCode(response.getStatus()));
// Get the web data
response = target().path("/file/" + file1Id + "/data")
.queryParam("size", "web")