aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src')
-rw-r--r--juick-server/src/main/resources/1x1.pngbin0 -> 95 bytes
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java26
2 files changed, 15 insertions, 11 deletions
diff --git a/juick-server/src/main/resources/1x1.png b/juick-server/src/main/resources/1x1.png
new file mode 100644
index 00000000..1914264c
--- /dev/null
+++ b/juick-server/src/main/resources/1x1.png
Binary files differ
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 177ced5e..924615d7 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
@@ -21,16 +21,14 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.juick.ExternalToken;
-import com.juick.Message;
-import com.juick.Tag;
-import com.juick.User;
+import com.juick.*;
import com.juick.server.*;
import com.juick.server.component.MessageEvent;
import com.juick.server.helpers.AnonymousUser;
import com.juick.server.helpers.CommandResult;
import com.juick.server.helpers.TagStats;
import com.juick.server.util.HttpUtils;
+import com.juick.server.util.ImageUtils;
import com.juick.service.*;
import com.juick.util.DateFormattersHolder;
import com.juick.util.MessageUtils;
@@ -84,11 +82,9 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
+import java.io.*;
import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.Timestamp;
@@ -170,7 +166,7 @@ public class ServerTests {
private static boolean isSetUp = false;
@Before
- public void setUp() throws IOException {
+ public void setUp() throws Exception {
Files.createDirectory(Paths.get(imgDir, "p"));
Files.createDirectory(Paths.get(imgDir, "photos-1024"));
Files.createDirectory(Paths.get(imgDir, "photos-512"));
@@ -190,8 +186,8 @@ public class ServerTests {
juick = userService.getUserByUID(juickId).orElseThrow(IllegalStateException::new);
String msgText = "Привет, я - Угнич";
-
- int mid = messagesService.createMessage(ugnich.getUid(), msgText, "png", null);
+ CommandResult result = commandsManager.processCommand(ugnich, msgText, URI.create("http://static.juick.com/settings/facebook.png"));
+ int mid = result.getNewMessage().get().getMid();
msg = messagesService.getMessage(mid);
tagService.createTag("тест");
juickTagId = tagService.createTag("juick");
@@ -1021,4 +1017,12 @@ public class ServerTests {
.with(httpBasic(juickName, juickPassword)))
.andExpect(status().isBadRequest());
}
+ @Test
+ public void attachmentSizeTests() throws URISyntaxException, IOException {
+ ImageUtils imageUtils = new ImageUtils(StringUtils.EMPTY, StringUtils.EMPTY);
+ Attachment attachment = imageUtils.getAttachment(new File(getClass().getClassLoader().getResource("Transparent.gif").toURI()));
+ assertThat(attachment.getHeight(), is(1));
+ assertThat(attachment.getWidth(), is(1));
+
+ }
}