diff options
Diffstat (limited to 'juick-server/src/test/java')
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; - } -} |