aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/test/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-12-11 22:55:51 +0300
committerGravatar Vitaly Takmazov2017-12-11 22:55:51 +0300
commit2be12ebce3d600804227f6b74374c8db37921139 (patch)
tree37d8d0578e8e4eb666a28dcf30e5b4bf8f6dabee /juick-www/src/test/java
parent18eebc950f6cf91ff9035c83836f0f56ed3d8bf4 (diff)
fix some tests
Diffstat (limited to 'juick-www/src/test/java')
-rw-r--r--juick-www/src/test/java/com/juick/www/WebAppTests.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/juick-www/src/test/java/com/juick/www/WebAppTests.java b/juick-www/src/test/java/com/juick/www/WebAppTests.java
index 927ea71c..aacfe8ce 100644
--- a/juick-www/src/test/java/com/juick/www/WebAppTests.java
+++ b/juick-www/src/test/java/com/juick/www/WebAppTests.java
@@ -39,13 +39,14 @@ import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.error.PebbleException;
import com.mitchellbosecke.pebble.template.PebbleTemplate;
import org.apache.commons.text.StringEscapeUtils;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.PropertySource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.mock.web.MockMultipartFile;
@@ -56,6 +57,7 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.util.FileSystemUtils;
import org.springframework.web.context.WebApplicationContext;
import javax.inject.Inject;
@@ -63,6 +65,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.Collections;
import java.util.stream.IntStream;
import java.util.stream.StreamSupport;
@@ -112,6 +116,8 @@ public class WebAppTests {
@Inject
PebbleEngine pebbleEngine;
+ @Value("${img_path:/tmp}")
+ String imgPath;
private static User ugnich, freefd;
private static String ugnichName, ugnichPassword, freefdName, freefdPassword;
@@ -119,7 +125,7 @@ public class WebAppTests {
private static boolean isSetUp = false;
@Before
- public void setup() {
+ public void setup() throws IOException {
if (!isSetUp) {
mockMvc = MockMvcBuilders.webAppContextSetup(wac)
.apply(springSecurity())
@@ -141,6 +147,18 @@ public class WebAppTests {
isSetUp = true;
}
+ Files.createDirectory(Paths.get(imgPath, "p"));
+ Files.createDirectory(Paths.get(imgPath, "photos-1024"));
+ Files.createDirectory(Paths.get(imgPath, "photos-512"));
+ Files.createDirectory(Paths.get(imgPath, "ps"));
+ }
+
+ @After
+ public void teardown() throws IOException {
+ FileSystemUtils.deleteRecursively(Paths.get(imgPath, "p"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgPath, "photos-1024"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgPath, "photos-512"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgPath, "ps"));
}
@Test