diff options
author | Vitaly Takmazov | 2021-10-23 08:09:05 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-10-23 08:10:06 +0300 |
commit | 4b96a9b2e71b7a67effdd55b26ca532ff849d0ef (patch) | |
tree | 597a9b268622a10b440f3b119c529e624b8fdb62 /src/test/java/com/juick/server | |
parent | 6b31c254b5a7ab6735c625459ba7936d9b2851e6 (diff) |
ImagesService -> StorageService
img_path -> storage_path property
Diffstat (limited to 'src/test/java/com/juick/server')
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index dc88cfbd..5aee3af8 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -132,6 +132,7 @@ import javax.xml.parsers.ParserConfigurationException; import java.io.*; import java.net.URI; import java.nio.charset.StandardCharsets; +import java.nio.file.CopyOption; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -203,7 +204,7 @@ public class ServerTests { @Inject private KeystoreManager keystoreManager; @Inject - private ImagesService imagesService; + private StorageService storageService; @Inject private PebbleEngine pebbleEngine; @Value("${ios_app_id:}") @@ -281,7 +282,7 @@ public class ServerTests { @BeforeEach public void setUp() throws Exception { - String imgDir = imagesService.getImageDirectory(); + String imgDir = storageService.getImageDirectory(); FileSystemUtils.deleteRecursively(Paths.get(imgDir, "p")); FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-1024")); FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-512")); @@ -312,7 +313,7 @@ public class ServerTests { @AfterEach public void teardown() throws IOException { - String imgDir = imagesService.getImageDirectory(); + String imgDir = storageService.getImageDirectory(); FileSystemUtils.deleteRecursively(Paths.get(imgDir, "p")); FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-1024")); FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-512")); @@ -761,7 +762,7 @@ public class ServerTests { @Test public void protocolTests() throws Exception { - String tmpDir = imagesService.getTemporaryDirectory(); + String tmpDir = storageService.getTemporaryDirectory(); User user = userService.createUser("me", "secret").orElseThrow(IllegalStateException::new); Tag yo = tagService.getTag("yo", true); Message msg = commandsManager @@ -1126,9 +1127,12 @@ public class ServerTests { @Test public void attachmentSizeTests() throws IOException { - Attachment attachment = imagesService.getImageMetadata(invisiblePixel.getURI().toASCIIString()); - assertThat(attachment.getHeight(), is(1)); - assertThat(attachment.getWidth(), is(1)); + String tmpPng = "tmp.png"; + Files.copy(defaultAvatar.getFile().toPath(), Paths.get(storageService.getTemporaryDirectory(), tmpPng), StandardCopyOption.REPLACE_EXISTING); + storageService.saveAvatar(tmpPng, serviceUser); + Attachment attachment = storageService.getAvatarMetadata(serviceUser); + assertThat(attachment.getHeight(), is(96)); + assertThat(attachment.getWidth(), is(96)); } @Test @@ -1188,7 +1192,7 @@ public class ServerTests { @Test public void cmykJpegShouldBeProcessedCorrectly() throws Exception { - String imgDir = imagesService.getImageDirectory(); + String imgDir = storageService.getImageDirectory(); CommandResult postJpgCmyk = commandsManager.processCommand(ugnich, "YO", cmykJpeg.getURI()); assertThat(postJpgCmyk.getNewMessage().isPresent(), is(true)); int mid = postJpgCmyk.getNewMessage().get().getMid(); @@ -1204,7 +1208,7 @@ public class ServerTests { @Test public void JpegWithoutJfifShouldBeProcessedCorrectly() throws Exception { - String imgDir = imagesService.getImageDirectory(); + String imgDir = storageService.getImageDirectory(); CommandResult postJpgCmyk = commandsManager.processCommand(ugnich, "YO", nojfif.getURI()); assertThat(postJpgCmyk.getNewMessage().isPresent(), is(true)); int mid = postJpgCmyk.getNewMessage().get().getMid(); @@ -1220,8 +1224,8 @@ public class ServerTests { @Test public void JpegFromJuickUriShouldBeProcessedCorrectly() throws Exception { - String imgDir = imagesService.getImageDirectory(); - String tmpDir = imagesService.getTemporaryDirectory(); + String imgDir = storageService.getImageDirectory(); + String tmpDir = storageService.getTemporaryDirectory(); Path tmpFile = Paths.get(tmpDir, "2915104.jpg"); Files.copy(Paths.get(new ClassPathResource("2915104.jpg").getURI()), tmpFile, StandardCopyOption.REPLACE_EXISTING); @@ -1248,7 +1252,7 @@ public class ServerTests { @Test public void changeExtensionWhenReceiveFileWithWrongContentType() throws Exception { - String tmpDir = imagesService.getTemporaryDirectory(); + String tmpDir = storageService.getTemporaryDirectory(); Path pngOutput = Paths.get(tmpDir, "cmyk.png"); Files.deleteIfExists(pngOutput); Files.copy(Paths.get(cmykJpeg.getURI()), pngOutput); @@ -2043,7 +2047,7 @@ public class ServerTests { @Test public void changeProfileOverApi() throws Exception { - String imgDir = imagesService.getImageDirectory(); + String imgDir = storageService.getImageDirectory(); ClassPathResource defaultAvatar = new ClassPathResource("static/av-96.png"); String hash = DigestUtils.md5DigestAsHex(IOUtils.toByteArray(defaultAvatar.getInputStream())); assertThat(webApp.getAvatarUrl(userService.getUserByName(freefdName)), |