diff options
Diffstat (limited to 'juick-server/src')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java | 3 | ||||
-rw-r--r-- | juick-server/src/test/java/com/juick/server/tests/ServerTests.java | 27 |
2 files changed, 13 insertions, 17 deletions
diff --git a/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java index 78838117..973c31fd 100644 --- a/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java +++ b/juick-server/src/main/java/com/juick/server/configuration/ApiAppConfiguration.java @@ -18,7 +18,6 @@ package com.juick.server.configuration; import com.google.common.base.Predicates; -import com.juick.configuration.DataConfiguration; import com.juick.server.WebsocketManager; import com.juick.server.api.rss.MessagesView; import com.juick.server.api.rss.RepliesView; @@ -51,8 +50,6 @@ import java.util.Collections; @EnableSwagger2 @EnableScheduling @EnableWebSocket -@Import({ApiSecurityConfig.class, BaseWebConfiguration.class, DataConfiguration.class, StorageConfiguration.class}) -@ComponentScan(basePackages = "com.juick.server") public class ApiAppConfiguration implements WebMvcConfigurer, WebSocketConfigurer { @Inject private WebsocketManager websocketManager; 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 b8c9d524..7220deeb 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 @@ -24,7 +24,6 @@ import com.juick.ExternalToken; import com.juick.Message; import com.juick.Tag; import com.juick.User; -import com.juick.configuration.DataConfiguration; import com.juick.server.EmailManager; import com.juick.server.XMPPBot; import com.juick.server.XMPPServer; @@ -36,13 +35,15 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; 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.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; @@ -51,7 +52,6 @@ import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; @@ -59,11 +59,9 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder; import rocks.xmpp.addr.Jid; -import rocks.xmpp.core.stanza.MessageEvent; import rocks.xmpp.core.stanza.model.Stanza; import rocks.xmpp.core.stanza.model.server.ServerMessage; -import javax.annotation.Nonnull; import javax.inject.Inject; import java.lang.reflect.InvocationTargetException; import java.text.ParseException; @@ -125,14 +123,8 @@ public class ServerTests { private static boolean isSetUp = false; - @Import({ApiAppConfiguration.class, DataConfiguration.class}) - @Configuration - static class TestConfig { - @Bean - ApplicationListener<com.juick.server.component.MessageEvent> listener() { - return event -> latch.countDown(); - } - } + @Mock + ApplicationListener<com.juick.server.component.MessageEvent> listener; @Before public void setUp() { @@ -156,6 +148,13 @@ public class ServerTests { msg = messagesService.getMessage(mid); tagService.createTag("ัะตัั"); juickTagId = tagService.createTag("juick"); + Mockito.doAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + latch.countDown(); + return null; + } + }).when(listener).onApplicationEvent(Mockito.any()); isSetUp = true; } } |