From 5b5ca32a22e2e8e95c9bca86ce23d19c4a69f83d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 2 Apr 2018 16:47:02 +0300 Subject: xmpp: move to library project --- juick-www/src/test/java/com/juick/WebAppTests.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'juick-www/src/test/java') diff --git a/juick-www/src/test/java/com/juick/WebAppTests.java b/juick-www/src/test/java/com/juick/WebAppTests.java index f644bef8..a9eb6926 100644 --- a/juick-www/src/test/java/com/juick/WebAppTests.java +++ b/juick-www/src/test/java/com/juick/WebAppTests.java @@ -23,10 +23,10 @@ import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.css.StyleElement; import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.juick.server.CommandsManager; import com.juick.server.XMPPConnection; -import com.juick.server.xmpp.router.XMPPRouter; import com.juick.server.XMPPServer; -import com.juick.server.configuration.ApiAppConfiguration; +import com.juick.server.xmpp.router.XMPPRouter; import com.juick.service.*; import com.juick.util.MessageUtils; import com.juick.www.WebApp; @@ -39,11 +39,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.io.ClassPathResource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.mock.web.MockMultipartFile; @@ -76,7 +74,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @AutoConfigureMockMvc -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = {Application.class, XMPPRouter.class}) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = {Application.class, XMPPRouter.class, XMPPServer.class, XMPPConnection.class, CommandsManager.class}) public class WebAppTests { @MockBean private ImagesService imagesService; @@ -98,6 +96,12 @@ public class WebAppTests { private JdbcTemplate jdbcTemplate; @Inject private SubscriptionService subscriptionService; + @Inject + private XMPPServer xmpp; + @Inject + private XMPPConnection routerConnection; + @Inject + private XMPPRouter xmppRouter; @Inject private PebbleEngine pebbleEngine; @@ -239,11 +243,6 @@ public class WebAppTests { } @Test public void postMessageTests() throws Exception { - ConfigurableApplicationContext context = new SpringApplicationBuilder( - ApiServer.class) - .properties("server.port=8081") - .run(); - XMPPServer xmpp = context.getBean(XMPPServer.class); assertThat(xmpp.getInConnections().size(), is(0)); mockMvc.perform(post("/post2").param("body", "yo")).andExpect(redirectedUrl("http://localhost/login")); MvcResult loginResult = mockMvc.perform(post("/login") -- cgit v1.2.3