From d6385d656a0af52d9509f76dccce1172b663f2d9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 31 Oct 2018 15:03:57 +0300 Subject: Fix tests --- .../test/java/com/juick/server/tests/ServerTests.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'juick-server/src/test') 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 e9f42ee3..d3654e90 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 @@ -212,6 +212,10 @@ public class ServerTests { @Before public void setUp() throws Exception { + FileSystemUtils.deleteRecursively(Paths.get(imgDir, "p")); + FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-1024")); + FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-512")); + FileSystemUtils.deleteRecursively(Paths.get(imgDir, "ps")); Files.createDirectory(Paths.get(imgDir, "p")); Files.createDirectory(Paths.get(imgDir, "photos-1024")); Files.createDirectory(Paths.get(imgDir, "photos-512")); @@ -1314,7 +1318,7 @@ public class ServerTests { return null; } }; - assertThat(getStatus.get().getInbound().size(), is(0)); + assertThat(getStatus.get().getInbound(), is(nullValue())); ConnectionIn test = new ConnectionIn(server, new Socket("localhost", server.getServerPort())); test.from.add(Jid.of("test")); server.getInConnections().clear(); @@ -1634,6 +1638,9 @@ public class ServerTests { } @Test public void notificationsTests() throws Exception { + jdbcTemplate.execute("DELETE FROM messages"); + jdbcTemplate.execute("DELETE FROM replies"); + jdbcTemplate.execute("DELETE FROM subscr_messages"); MvcResult loginResult = mockMvc.perform(post("/login") .param("username", freefdName) .param("password", freefdPassword)) @@ -1664,10 +1671,12 @@ public class ServerTests { .andExpect(status().isOk()) .andReturn(); String outputDir = System.getProperty("io.springfox.staticdocs.outputDir"); - Files.createDirectories(Paths.get(outputDir)); - BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputDir, "swagger.json"), StandardCharsets.UTF_8); - writer.write(result.getResponse().getContentAsString()); - writer.flush(); + if (StringUtils.isNotEmpty(outputDir)) { + Files.createDirectories(Paths.get(outputDir)); + BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputDir, "swagger.json"), StandardCharsets.UTF_8); + writer.write(result.getResponse().getContentAsString()); + writer.flush(); + } } @Test public void newMessageShouldNotContainDuplicatedTags() throws Exception { -- cgit v1.2.3