Example usage for org.springframework.web.socket.adapter.standard StandardWebSocketSession initializeNativeSession

List of usage examples for org.springframework.web.socket.adapter.standard StandardWebSocketSession initializeNativeSession

Introduction

In this page you can find the example usage for org.springframework.web.socket.adapter.standard StandardWebSocketSession initializeNativeSession.

Prototype

@Override
    public void initializeNativeSession(Session session) 

Source Link

Usage

From source file:ch.rasc.wampspring.broker.SimpleBrokerMessageHandlerTests.java

@SuppressWarnings("resource")
@Test//from  ww w.  j a v  a2 s  . c o m
public void testCleanupMessage() {

    this.messageHandler.handleMessage(subscribeMessage("sess1", "/foo"));
    this.messageHandler.handleMessage(subscribeMessage("sess2", "/foo"));

    Session nativeSession = Mockito.mock(Session.class);
    Mockito.when(nativeSession.getId()).thenReturn("sess1");
    StandardWebSocketSession wsSession = new StandardWebSocketSession(null, null, null, null);
    wsSession.initializeNativeSession(nativeSession);
    UnsubscribeMessage cleanupMessage = UnsubscribeMessage.createCleanupMessage(wsSession);
    this.messageHandler.handleMessage(cleanupMessage);

    this.messageHandler.handleMessage(eventMessage("sess1", "/foo", "message1"));
    this.messageHandler.handleMessage(eventMessage("sess2", "/bar", "message2"));

    verify(this.clientOutboundChannel, times(1)).send(this.messageCaptor.capture());
    assertCapturedMessage(eventMessage("sess2", "/foo", "message1"));
}