diff options
author | 2018-08-09 18:21:51 +0300 | |
---|---|---|
committer | 2018-08-09 18:21:51 +0300 | |
commit | babb3a50a1c7e6101980a9577364b169b5c6654c (patch) | |
tree | 27f82bb04c79587bd9d844e916102eb6cc49d1ca /juick-server/src/test | |
parent | 244c5aac19f19b64d4e066b1e66da72f704cf36a (diff) |
Fix attachments errors
Diffstat (limited to 'juick-server/src/test')
-rw-r--r-- | juick-server/src/test/java/com/juick/server/tests/ServerTests.java | 21 | ||||
-rw-r--r-- | juick-server/src/test/resources/2915104.jpg | bin | 0 -> 227253 bytes |
2 files changed, 18 insertions, 3 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index b468daff..b4d91b79 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -79,9 +79,7 @@ import javax.xml.parsers.ParserConfigurationException; import java.io.*; import java.net.URI; import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.nio.file.*; import java.sql.Timestamp; import java.time.Instant; import java.util.*; @@ -1089,6 +1087,23 @@ public class ServerTests { assertThat(postJpgCmyk.getNewMessage().get().getAttachment().getSmall().getHeight(), is(512)); } @Test + public void JpegFromJuickUriShouldBeProcessedCorrectly() throws Exception { + Path tmpFile = Paths.get(tmpDir, "2915104.jpg"); + Files.copy(Paths.get(ClassLoader.getSystemResource("2915104.jpg").toURI()), tmpFile, StandardCopyOption.REPLACE_EXISTING); + assertThat(tmpFile.toFile().exists(), is(true)); + CommandResult postJpgiPhone = commandsManager.processCommand(ugnich, "YO", URI.create("juick://2915104.jpg")); + assertThat(postJpgiPhone.getNewMessage().isPresent(), is(true)); + int mid = postJpgiPhone.getNewMessage().get().getMid(); + File originalFile = Paths.get(imgDir, "p", String.format("%d.jpg", mid)).toFile(); + assertThat(originalFile.exists(), is(true)); + File mediumFile = Paths.get(imgDir, "photos-1024", String.format("%d.jpg", mid)).toFile(); + assertThat(mediumFile.exists(), is(true)); + assertThat(postJpgiPhone.getNewMessage().get().getAttachment().getWidth(), is(1280)); + assertThat(postJpgiPhone.getNewMessage().get().getAttachment().getHeight(), is(1280)); + assertThat(postJpgiPhone.getNewMessage().get().getAttachment().getMedium().getHeight(), is(1024)); + assertThat(postJpgiPhone.getNewMessage().get().getAttachment().getSmall().getHeight(), is(512)); + } + @Test public void changeExtensionWhenReceiveFileWithWrongContentType() throws Exception { Path pngOutput = Paths.get(tmpDir, "cmyk.png"); Files.deleteIfExists(pngOutput); diff --git a/juick-server/src/test/resources/2915104.jpg b/juick-server/src/test/resources/2915104.jpg Binary files differnew file mode 100644 index 00000000..7f0fc3ba --- /dev/null +++ b/juick-server/src/test/resources/2915104.jpg |