diff options
author | Vitaly Takmazov | 2017-12-11 22:55:51 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-12-11 22:55:51 +0300 |
commit | 2be12ebce3d600804227f6b74374c8db37921139 (patch) | |
tree | 37d8d0578e8e4eb666a28dcf30e5b4bf8f6dabee | |
parent | 18eebc950f6cf91ff9035c83836f0f56ed3d8bf4 (diff) |
fix some tests
-rw-r--r-- | juick-api/src/test/java/com/juick/api/tests/MessagesTests.java | 3 | ||||
-rw-r--r-- | juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java | 2 | ||||
-rw-r--r-- | juick-server-jdbc/src/test/java/com/juick/configuration/MockStorageConfiguration.java (renamed from juick-api/src/test/java/com/juick/api/tests/configuration/MockStorageConfiguration.java) | 2 | ||||
-rw-r--r-- | juick-www/src/test/java/com/juick/www/WebAppTests.java | 22 |
4 files changed, 24 insertions, 5 deletions
diff --git a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java index 07e649ec..0022c966 100644 --- a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java +++ b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java @@ -25,7 +25,6 @@ import com.juick.Tag; import com.juick.User; import com.juick.api.configuration.ApiAppConfiguration; import com.juick.api.configuration.ApiSecurityConfig; -import com.juick.api.tests.configuration.MockStorageConfiguration; import com.juick.configuration.RepositoryConfiguration; import com.juick.server.helpers.TagStats; import com.juick.service.ImagesService; @@ -65,7 +64,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * Created by vitalyster on 25.11.2016. */ @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = {ApiAppConfiguration.class, ApiSecurityConfig.class, RepositoryConfiguration.class, MockStorageConfiguration.class}) +@ContextConfiguration(classes = {ApiAppConfiguration.class, ApiSecurityConfig.class, RepositoryConfiguration.class}) @WebAppConfiguration public class MessagesTests extends AbstractJUnit4SpringContextTests { diff --git a/juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java b/juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java index cc02b07d..9688e935 100644 --- a/juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java +++ b/juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java @@ -17,6 +17,7 @@ package com.juick.components.test; +import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.core.Appender; @@ -62,6 +63,7 @@ public class NotificationTests { ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); final Appender mockAppender = mock(Appender.class); when(mockAppender.getName()).thenReturn("MOCK"); + root.setLevel(Level.DEBUG); root.addAppender(mockAppender); cleanUp.cleanupTokens(); verify(mockAppender).doAppend(argThat(argument -> diff --git a/juick-api/src/test/java/com/juick/api/tests/configuration/MockStorageConfiguration.java b/juick-server-jdbc/src/test/java/com/juick/configuration/MockStorageConfiguration.java index 374bec0a..bfaa26b9 100644 --- a/juick-api/src/test/java/com/juick/api/tests/configuration/MockStorageConfiguration.java +++ b/juick-server-jdbc/src/test/java/com/juick/configuration/MockStorageConfiguration.java @@ -1,4 +1,4 @@ -package com.juick.api.tests.configuration; +package com.juick.configuration; import com.juick.service.ImagesService; import com.juick.service.MockImagesService; 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 |