diff options
author | Vitaly Takmazov | 2018-03-15 23:24:13 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-03-15 23:24:13 +0300 |
commit | ef9bb70fa1fe3744e971837eb78c6c004cd1e989 (patch) | |
tree | cee55dfcdcf9daf29c4835b200e1277a5d90b101 /juick-xmpp-wip/src/test/java/com/juick/xmpp | |
parent | 55ec9f370d76a76aa33e290a093995d576e70bdb (diff) |
boot: simplify test configuration
Diffstat (limited to 'juick-xmpp-wip/src/test/java/com/juick/xmpp')
-rw-r--r-- | juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java b/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java index 2cad5fb4..72d9dfe9 100644 --- a/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java +++ b/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java @@ -17,25 +17,16 @@ package com.juick.xmpp; -import com.gargoylesoftware.htmlunit.WebClient; import com.juick.components.XMPPRouter; import com.juick.components.configuration.BotAppConfiguration; -import com.juick.configuration.MockDataConfiguration; -import com.juick.service.MessengerService; -import com.juick.service.PrivacyQueriesService; -import com.juick.service.ShowQueriesService; -import org.junit.Before; +import com.juick.configuration.DataConfiguration; +import com.juick.service.ImagesService; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder; -import org.springframework.web.context.WebApplicationContext; +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.test.context.junit4.SpringRunner; import rocks.xmpp.addr.Jid; import rocks.xmpp.core.XmppException; import rocks.xmpp.core.session.ConnectionEvent; @@ -52,40 +43,12 @@ import java.util.concurrent.ExecutorService; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; -@RunWith(SpringJUnit4ClassRunner.class) -@WebAppConfiguration -@ContextConfiguration +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, + classes = { BotAppConfiguration.class, DataConfiguration.class}) public class XMPPTests { - @Configuration - @Import(value = { - BotAppConfiguration.class, MockDataConfiguration.class - }) - static class Config { - @Bean - public ShowQueriesService showQueriesService() { - return Mockito.mock(ShowQueriesService.class); - } - @Bean - public PrivacyQueriesService privacyQueriesService() { - return Mockito.mock(PrivacyQueriesService.class); - } - @Bean - public MessengerService messengerService() { - return Mockito.mock(MessengerService.class); - } - } - - @Inject - private WebApplicationContext wac; - - private WebClient webClient; - - @Before - public void setup() { - webClient = MockMvcWebClientBuilder.webAppContextSetup(this.wac).build(); - webClient.getOptions().setJavaScriptEnabled(false); - } - + @MockBean + ImagesService imagesService; @Inject XMPPRouter router; @Inject |