From babb3a50a1c7e6101980a9577364b169b5c6654c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 9 Aug 2018 18:21:51 +0300 Subject: Fix attachments errors --- .../java/com/juick/server/tests/ServerTests.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'juick-server/src/test/java/com/juick/server/tests') 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); -- cgit v1.2.3