From 1ae03ea2f7866b30796d7f8ae925c53d7d98c1b3 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 29 Mar 2019 16:21:42 +0300 Subject: Using @Resource where possible --- src/test/java/com/juick/server/tests/ServerTests.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/test/java/com') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index ea99fac3..f08c49f5 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -220,6 +220,8 @@ public class ServerTests { private Resource noteWithDocument; @Value("classpath:2936611-57.jpg") private Resource jpegNoJfifTiff; + @Value("classpath:Transparent.gif") + private Resource invisiblePixel; @Inject private KeystoreManager testKeystoreManager; @@ -954,8 +956,7 @@ public class ServerTests { int freefdrid = messagesService.createReply(mid, 0, freefd, "again", null); mockMvc.perform(get(String.format("/api/thread/mark_read/%d-%d.gif?hash=%s", mid, freefdrid, ugnichHash))) .andExpect(status().isOk()) - .andExpect(content().bytes(IOUtils.toByteArray( - Objects.requireNonNull(getClass().getClassLoader().getResource("Transparent.gif"))))); + .andExpect(content().bytes(IOUtils.toByteArray(invisiblePixel.getInputStream()))); assertThat(lastRead.apply(ugnich, mid), is(freefdrid)); privacyQueriesService.blacklistUser(ugnich, freefd); int newfreefdrid = messagesService.createReply(mid, 0, freefd, "from ban", null); @@ -1083,9 +1084,9 @@ public class ServerTests { .andExpect(status().isBadRequest()); } @Test - public void attachmentSizeTests() throws URISyntaxException, IOException { + public void attachmentSizeTests() throws IOException { ImageUtils imageUtils = new ImageUtils(StringUtils.EMPTY, StringUtils.EMPTY); - Attachment attachment = imageUtils.getAttachment(new File(getClass().getClassLoader().getResource("Transparent.gif").toURI())); + Attachment attachment = imageUtils.getAttachment(new File(invisiblePixel.getURI())); assertThat(attachment.getHeight(), is(1)); assertThat(attachment.getWidth(), is(1)); } -- cgit v1.2.3