aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-10-23 05:37:09 +0300
committerGravatar Vitaly Takmazov2021-10-23 05:37:09 +0300
commit37e6d26e02d51a4de257200bbf207712fa3a6980 (patch)
treed010d09492475a310c0a4217af46799b120e70cb /src/test/java/com/juick
parent26e4c1c4046914f064046229e927461d93bce534 (diff)
ImagesService refactoring
* Merge ImagesService and ImageUtils * add avatar metadata to RSS feeds
Diffstat (limited to 'src/test/java/com/juick')
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index aceed0b9..dc88cfbd 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -202,10 +202,8 @@ public class ServerTests {
private ServerManager serverManager;
@Inject
private KeystoreManager keystoreManager;
- @Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
- private String tmpDir;
- @Value("${img_path:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
- private String imgDir;
+ @Inject
+ private ImagesService imagesService;
@Inject
private PebbleEngine pebbleEngine;
@Value("${ios_app_id:}")
@@ -283,6 +281,7 @@ public class ServerTests {
@BeforeEach
public void setUp() throws Exception {
+ String imgDir = imagesService.getImageDirectory();
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "p"));
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-1024"));
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-512"));
@@ -313,6 +312,7 @@ public class ServerTests {
@AfterEach
public void teardown() throws IOException {
+ String imgDir = imagesService.getImageDirectory();
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "p"));
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-1024"));
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-512"));
@@ -761,6 +761,7 @@ public class ServerTests {
@Test
public void protocolTests() throws Exception {
+ String tmpDir = imagesService.getTemporaryDirectory();
User user = userService.createUser("me", "secret").orElseThrow(IllegalStateException::new);
Tag yo = tagService.getTag("yo", true);
Message msg = commandsManager
@@ -1125,8 +1126,7 @@ public class ServerTests {
@Test
public void attachmentSizeTests() throws IOException {
- ImageUtils imageUtils = new ImageUtils(StringUtils.EMPTY, StringUtils.EMPTY);
- Attachment attachment = imageUtils.getAttachment(new File(invisiblePixel.getURI()));
+ Attachment attachment = imagesService.getImageMetadata(invisiblePixel.getURI().toASCIIString());
assertThat(attachment.getHeight(), is(1));
assertThat(attachment.getWidth(), is(1));
}
@@ -1188,6 +1188,7 @@ public class ServerTests {
@Test
public void cmykJpegShouldBeProcessedCorrectly() throws Exception {
+ String imgDir = imagesService.getImageDirectory();
CommandResult postJpgCmyk = commandsManager.processCommand(ugnich, "YO", cmykJpeg.getURI());
assertThat(postJpgCmyk.getNewMessage().isPresent(), is(true));
int mid = postJpgCmyk.getNewMessage().get().getMid();
@@ -1203,6 +1204,7 @@ public class ServerTests {
@Test
public void JpegWithoutJfifShouldBeProcessedCorrectly() throws Exception {
+ String imgDir = imagesService.getImageDirectory();
CommandResult postJpgCmyk = commandsManager.processCommand(ugnich, "YO", nojfif.getURI());
assertThat(postJpgCmyk.getNewMessage().isPresent(), is(true));
int mid = postJpgCmyk.getNewMessage().get().getMid();
@@ -1218,6 +1220,8 @@ public class ServerTests {
@Test
public void JpegFromJuickUriShouldBeProcessedCorrectly() throws Exception {
+ String imgDir = imagesService.getImageDirectory();
+ String tmpDir = imagesService.getTemporaryDirectory();
Path tmpFile = Paths.get(tmpDir, "2915104.jpg");
Files.copy(Paths.get(new ClassPathResource("2915104.jpg").getURI()), tmpFile,
StandardCopyOption.REPLACE_EXISTING);
@@ -1244,6 +1248,7 @@ public class ServerTests {
@Test
public void changeExtensionWhenReceiveFileWithWrongContentType() throws Exception {
+ String tmpDir = imagesService.getTemporaryDirectory();
Path pngOutput = Paths.get(tmpDir, "cmyk.png");
Files.deleteIfExists(pngOutput);
Files.copy(Paths.get(cmykJpeg.getURI()), pngOutput);
@@ -2038,6 +2043,7 @@ public class ServerTests {
@Test
public void changeProfileOverApi() throws Exception {
+ String imgDir = imagesService.getImageDirectory();
ClassPathResource defaultAvatar = new ClassPathResource("static/av-96.png");
String hash = DigestUtils.md5DigestAsHex(IOUtils.toByteArray(defaultAvatar.getInputStream()));
assertThat(webApp.getAvatarUrl(userService.getUserByName(freefdName)),