org.springframework.web.socket.handler.AbstractWebSocketHandler Java Examples

The following examples show how to use org.springframework.web.socket.handler.AbstractWebSocketHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSocketIntegrationTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void unsolicitedPongWithEmptyPayload() throws Exception {

	String url = getWsBaseUrl() + "/ws";
	WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get();

	TestWebSocketHandler serverHandler = this.wac.getBean(TestWebSocketHandler.class);
	serverHandler.setWaitMessageCount(1);

	session.sendMessage(new PongMessage());

	serverHandler.await();
	assertNull(serverHandler.getTransportError());
	assertEquals(1, serverHandler.getReceivedMessages().size());
	assertEquals(PongMessage.class, serverHandler.getReceivedMessages().get(0).getClass());
}
 
Example #2
Source File: StandardWebSocketClientTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setup() {
	this.headers = new WebSocketHttpHeaders();
	this.wsHandler = new AbstractWebSocketHandler() {
	};
	this.wsContainer = mock(WebSocketContainer.class);
	this.wsClient = new StandardWebSocketClient(this.wsContainer);
}
 
Example #3
Source File: WebSocketConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void registerWebSocketHandler() throws Exception {
	WebSocketSession session = this.webSocketClient.doHandshake(
			new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/ws").get();

	TestHandler serverHandler = this.wac.getBean(TestHandler.class);
	assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));

	session.close();
}
 
Example #4
Source File: WebSocketConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void registerWebSocketHandlerWithSockJS() throws Exception {
	WebSocketSession session = this.webSocketClient.doHandshake(
			new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/sockjs/websocket").get();

	TestHandler serverHandler = this.wac.getBean(TestHandler.class);
	assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));

	session.close();
}
 
Example #5
Source File: WebSocketHandshakeTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test  // SPR-12727
public void unsolicitedPongWithEmptyPayload() throws Exception {
	String url = getWsBaseUrl() + "/ws";
	WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get();

	TestWebSocketHandler serverHandler = this.wac.getBean(TestWebSocketHandler.class);
	serverHandler.setWaitMessageCount(1);

	session.sendMessage(new PongMessage());

	serverHandler.await();
	assertNull(serverHandler.getTransportError());
	assertEquals(1, serverHandler.getReceivedMessages().size());
	assertEquals(PongMessage.class, serverHandler.getReceivedMessages().get(0).getClass());
}
 
Example #6
Source File: StandardWebSocketClientTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setup() {
	this.headers = new WebSocketHttpHeaders();
	this.wsHandler = new AbstractWebSocketHandler() {
	};
	this.wsContainer = mock(WebSocketContainer.class);
	this.wsClient = new StandardWebSocketClient(this.wsContainer);
}
 
Example #7
Source File: WebSocketConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void registerWebSocketHandler() throws Exception {
	WebSocketSession session = this.webSocketClient.doHandshake(
			new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/ws").get();

	TestHandler serverHandler = this.wac.getBean(TestHandler.class);
	assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));

	session.close();
}
 
Example #8
Source File: WebSocketConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void registerWebSocketHandlerWithSockJS() throws Exception {
	WebSocketSession session = this.webSocketClient.doHandshake(
			new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/sockjs/websocket").get();

	TestHandler serverHandler = this.wac.getBean(TestHandler.class);
	assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));

	session.close();
}
 
Example #9
Source File: WebSocketHandshakeTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test  // SPR-12727
public void unsolicitedPongWithEmptyPayload() throws Exception {
	String url = getWsBaseUrl() + "/ws";
	WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get();

	TestWebSocketHandler serverHandler = this.wac.getBean(TestWebSocketHandler.class);
	serverHandler.setWaitMessageCount(1);

	session.sendMessage(new PongMessage());

	serverHandler.await();
	assertNull(serverHandler.getTransportError());
	assertEquals(1, serverHandler.getReceivedMessages().size());
	assertEquals(PongMessage.class, serverHandler.getReceivedMessages().get(0).getClass());
}
 
Example #10
Source File: StandardWebSocketClientTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	this.headers = new WebSocketHttpHeaders();
	this.wsHandler = new AbstractWebSocketHandler() {
	};
	this.wsContainer = mock(WebSocketContainer.class);
	this.wsClient = new StandardWebSocketClient(this.wsContainer);
}
 
Example #11
Source File: WebSocketConfigurationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void registerWebSocketHandler() throws Exception {
	WebSocketSession session = this.webSocketClient.doHandshake(
			new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/ws").get();

	TestHandler serverHandler = this.wac.getBean(TestHandler.class);
	assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));

	session.close();
}
 
Example #12
Source File: WebSocketConfigurationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void registerWebSocketHandlerWithSockJS() throws Exception {
	WebSocketSession session = this.webSocketClient.doHandshake(
			new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/sockjs/websocket").get();

	TestHandler serverHandler = this.wac.getBean(TestHandler.class);
	assertTrue(serverHandler.connectLatch.await(2, TimeUnit.SECONDS));

	session.close();
}