Search in sources :

Example 11 with CloseStatus

use of org.springframework.web.socket.CloseStatus in project spring-framework by spring-projects.

the class ClientSockJsSessionTests method closeWithStatusOutOfRange.

@Test
public void closeWithStatusOutOfRange() throws Exception {
    this.session.handleFrame(SockJsFrame.openFrame().getContent());
    this.thrown.expect(IllegalArgumentException.class);
    this.thrown.expectMessage("Invalid close status");
    this.session.close(new CloseStatus(2999, "reason"));
}
Also used : CloseStatus(org.springframework.web.socket.CloseStatus) Test(org.junit.Test)

Example 12 with CloseStatus

use of org.springframework.web.socket.CloseStatus in project spring-framework by spring-projects.

the class ClientSockJsSessionTests method closeWithStatus.

@Test
public void closeWithStatus() throws Exception {
    this.session.handleFrame(SockJsFrame.openFrame().getContent());
    this.session.close(new CloseStatus(3000, "reason"));
    assertThat(this.session.disconnectStatus, equalTo(new CloseStatus(3000, "reason")));
}
Also used : CloseStatus(org.springframework.web.socket.CloseStatus) Test(org.junit.Test)

Example 13 with CloseStatus

use of org.springframework.web.socket.CloseStatus in project spring-framework by spring-projects.

the class SockJsSessionTests method closeWithWriteFrameExceptions.

@Test
public void closeWithWriteFrameExceptions() throws Exception {
    this.session.setExceptionOnWrite(new IOException());
    this.session.delegateConnectionEstablished();
    this.session.setActive(true);
    this.session.close();
    assertEquals(new CloseStatus(3000, "Go away!"), this.session.getCloseStatus());
    assertClosed();
}
Also used : IOException(java.io.IOException) CloseStatus(org.springframework.web.socket.CloseStatus) Test(org.junit.Test)

Aggregations

CloseStatus (org.springframework.web.socket.CloseStatus)13 Test (org.junit.Test)9 IOException (java.io.IOException)3 ClientHttpResponse (org.springframework.http.client.ClientHttpResponse)3 TextMessage (org.springframework.web.socket.TextMessage)3 ClientCallback (io.undertow.client.ClientCallback)1 ClientExchange (io.undertow.client.ClientExchange)1 ClientResponse (io.undertow.client.ClientResponse)1 HttpHeaders (org.springframework.http.HttpHeaders)1 HttpStatus (org.springframework.http.HttpStatus)1 MessageHeaders (org.springframework.messaging.MessageHeaders)1 StompEncoder (org.springframework.messaging.simp.stomp.StompEncoder)1 StompHeaderAccessor (org.springframework.messaging.simp.stomp.StompHeaderAccessor)1 SimpUser (org.springframework.messaging.simp.user.SimpUser)1 HttpServerErrorException (org.springframework.web.client.HttpServerErrorException)1 Jackson2SockJsMessageCodec (org.springframework.web.socket.sockjs.frame.Jackson2SockJsMessageCodec)1 SockJsFrame (org.springframework.web.socket.sockjs.frame.SockJsFrame)1 StreamSinkChannel (org.xnio.channels.StreamSinkChannel)1