aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-03-28 11:27:29 +0300
committerGravatar Vitaly Takmazov2018-03-28 12:10:11 +0300
commit94f85e2ec113efee03def8ae9539cdaee21cccf9 (patch)
tree6946277aef3931e4c5aebd060ff2b5264c8599e3 /juick-server/src/test/java/com
parentacd6d0180c67a62079652bd879a3e7c661fc2c90 (diff)
drop sphinx search and use datasource autoconfiguration
Diffstat (limited to 'juick-server/src/test/java/com')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java27
1 files changed, 13 insertions, 14 deletions
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;
}
}