aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-07-24 21:34:23 +0300
committerGravatar Vitaly Takmazov2018-07-24 21:34:23 +0300
commit09552f180282bd845bac585408f27e1504e7897d (patch)
treef9de223feed361cfc1b7ca5e8e50c0c43db2c98f /juick-server/src
parentee61f91b3e4541d405bd92c2ba2486ceb4c3b46f (diff)
drop incompleted websocket tests
Diffstat (limited to 'juick-server/src')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java12
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/WebsocketClientConfig.java52
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/WebsocketClientHandler.java36
3 files changed, 0 insertions, 100 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 824a10e5..61c51b44 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
@@ -851,18 +851,6 @@ public class ServerTests {
mockMvc.perform(post("/mail").with(httpBasic(juickName, juickPassword)).content(mail))
.andExpect(status().isOk());
}
- @Test
- public void websocketsTest() throws Exception {
- ConfigurableApplicationContext context = new SpringApplicationBuilder(
- WebsocketClientConfig.class, PropertyPlaceholderAutoConfiguration.class)
- .run("--spring.main.web_environment=false");
- long count = context.getBean(WebsocketClientConfig.class).getLatch().getCount();
- WebsocketClientHandler handler = context.getBean(WebsocketClientHandler.class);
- assertThat(handler.getLastMessage(), is("Authorization required"));
- context.close();
- Assert.assertThat(count, equalTo(0L));
- mockMvc.perform(get("/ws/_all")).andExpect(status().isBadRequest());
- }
@Test
public void recommendTests() throws Exception {
diff --git a/juick-server/src/test/java/com/juick/server/tests/WebsocketClientConfig.java b/juick-server/src/test/java/com/juick/server/tests/WebsocketClientConfig.java
deleted file mode 100644
index 074be9b0..00000000
--- a/juick-server/src/test/java/com/juick/server/tests/WebsocketClientConfig.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.juick.server.tests;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.client.WebSocketConnectionManager;
-import org.springframework.web.socket.client.standard.StandardWebSocketClient;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-@Configuration
-public class WebsocketClientConfig implements CommandLineRunner {
- private static Logger logger = LoggerFactory.getLogger(ServerTests.class);
- @Bean
- public WebsocketClientHandler handler() {
- return new WebsocketClientHandler(latch);
- }
- @Bean
- ServletWebServerFactory servletWebServerFactory(){
- return new TomcatServletWebServerFactory();
- }
- @Bean
- public WebSocketConnectionManager connectionManager() {
- WebSocketConnectionManager manager = new WebSocketConnectionManager(client(),
- handler(),
- "ws://localhost:8080/ws/_all");
- manager.setAutoStartup(true);
- return manager;
- }
-
- @Bean
- public StandardWebSocketClient client() {
- return new StandardWebSocketClient();
- }
- private final CountDownLatch latch = new CountDownLatch(1);
-
- @Override
- public void run(String... args) throws Exception {
- if (latch.await(10, TimeUnit.SECONDS)) {
- logger.info("client connected");
- }
- }
-
- public CountDownLatch getLatch() {
- return latch;
- }
-}
diff --git a/juick-server/src/test/java/com/juick/server/tests/WebsocketClientHandler.java b/juick-server/src/test/java/com/juick/server/tests/WebsocketClientHandler.java
deleted file mode 100644
index ae92ccf0..00000000
--- a/juick-server/src/test/java/com/juick/server/tests/WebsocketClientHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.juick.server.tests;
-
-import org.springframework.web.socket.TextMessage;
-import org.springframework.web.socket.WebSocketSession;
-import org.springframework.web.socket.handler.TextWebSocketHandler;
-
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-
-class WebsocketClientHandler extends TextWebSocketHandler {
- private final CountDownLatch latch;
- private WebSocketSession session;
- private String lastMessage;
- public WebsocketClientHandler(CountDownLatch latch) {
- this.latch = latch;
- }
- @Override
- public void afterConnectionEstablished(WebSocketSession session) throws IOException {
- this.session = session;
- session.sendMessage(new TextMessage("PING"));
- }
-
- @Override
- protected void handleTextMessage(WebSocketSession session, TextMessage message) {
- this.lastMessage = message.getPayload();
- latch.countDown();
- }
-
- public WebSocketSession getSession() {
- return session;
- }
-
- public String getLastMessage() {
- return lastMessage;
- }
-}