aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-12-12 10:01:30 +0300
committerGravatar Vitaly Takmazov2018-12-12 10:01:30 +0300
commitf8603ba2dcfc311e3ed9b6f7ade23db204f2d99a (patch)
treef752cb2786c2df80d742bddbd23147a53927e165
parent1dc570a8aaaa8657eb4faa7283e30a5fde93d321 (diff)
Fix avatar tests
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index b914aed0..01aa298b 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -221,10 +221,16 @@ public class ServerTests {
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-1024"));
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-512"));
FileSystemUtils.deleteRecursively(Paths.get(imgDir, "ps"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgDir, "a"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgDir, "ao"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgDir, "as"));
Files.createDirectory(Paths.get(imgDir, "p"));
Files.createDirectory(Paths.get(imgDir, "photos-1024"));
Files.createDirectory(Paths.get(imgDir, "photos-512"));
Files.createDirectory(Paths.get(imgDir, "ps"));
+ Files.createDirectory(Paths.get(imgDir, "a"));
+ Files.createDirectory(Paths.get(imgDir, "ao"));
+ Files.createDirectory(Paths.get(imgDir, "as"));
if (!isSetUp) {
ugnichName = "ugnich";
ugnichPassword = "secret";
@@ -1868,14 +1874,15 @@ public class ServerTests {
String hash = DigestUtils.md5DigestAsHex(IOUtils.toByteArray(defaultAvatar.getInputStream()));
assertThat(webApp.getAvatarUrl(userService.getUserByName(freefdName)), is(String.format("http://localhost:8080/av-96-%s.png", hash)));
- ClassPathResource newAvatar = new ClassPathResource("cmyk.jpg");
+ ClassPathResource newAvatar = new ClassPathResource("static/durov.png");
byte[] newAvatarData = IOUtils.toByteArray(newAvatar.getInputStream());
mockMvc.perform(MockMvcRequestBuilders.multipart("/api/me/upload")
.file("avatar", newAvatarData)
.with(httpBasic(freefdName, freefdPassword))
).andExpect(status().isOk());
String newHash = DigestUtils.md5DigestAsHex(newAvatarData);
- assertThat(webApp.getAvatarUrl(userService.getUserByName(freefdName)), is(String.format("http://localhost:8080/i/a/%d-%s.png", freefd.getUid(), newHash)));
+ URI newUri = Paths.get(imgDir, "ao", String.format("%d.png", freefd.getUid())).toUri();
+ assertThat(DigestUtils.md5DigestAsHex(IOUtils.toByteArray(newUri)), is(newHash));
}
@Test
public void varyMvcResponse() throws Exception {