aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/test')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java22
1 files changed, 13 insertions, 9 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 e4e5f298..824a10e5 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
@@ -1101,14 +1101,18 @@ public class ServerTests {
@Test
public void changeExtensionWhenReceiveFileWithWrongContentType() throws Exception {
Path pngOutput = Paths.get(tmpDir, "cmyk.png");
- Files.delete(pngOutput);
- Files.copy(getClass().getClassLoader().getResourceAsStream("cmyk.jpg"), pngOutput);
- assertThat(pngOutput.toFile().exists(), is(true));
- CommandResult postJpgCmyk = commandsManager.processCommand(ugnich, "YO", pngOutput.toUri());
- assertThat(postJpgCmyk.getNewMessage().isPresent(), is(true));
- assertThat(postJpgCmyk.getNewMessage().get().getAttachmentType(), is("jpg"));
- CommandResult replyJpgCmyk = commandsManager.processCommand(ugnich, String.format("#%d YO", postJpgCmyk.getNewMessage().get().getMid()), pngOutput.toUri());
- assertThat(replyJpgCmyk.getNewMessage().isPresent(), is(true));
- assertThat(replyJpgCmyk.getNewMessage().get().getAttachmentType(), is("jpg"));
+ Files.deleteIfExists(pngOutput);
+ try {
+ Files.copy(getClass().getClassLoader().getResourceAsStream("cmyk.jpg"), pngOutput);
+ assertThat(pngOutput.toFile().exists(), is(true));
+ CommandResult postJpgCmyk = commandsManager.processCommand(ugnich, "YO", pngOutput.toUri());
+ assertThat(postJpgCmyk.getNewMessage().isPresent(), is(true));
+ assertThat(postJpgCmyk.getNewMessage().get().getAttachmentType(), is("jpg"));
+ CommandResult replyJpgCmyk = commandsManager.processCommand(ugnich, String.format("#%d YO", postJpgCmyk.getNewMessage().get().getMid()), pngOutput.toUri());
+ assertThat(replyJpgCmyk.getNewMessage().isPresent(), is(true));
+ assertThat(replyJpgCmyk.getNewMessage().get().getAttachmentType(), is("jpg"));
+ } finally {
+ Files.deleteIfExists(pngOutput);
+ }
}
}