Package org.springframework.web.socket

Examples of org.springframework.web.socket.WebSocketHandler


  }

  @Test
  public void doNotCauseSessionCreation() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);

    HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
    interceptor.beforeHandshake(this.request, this.response, wsHandler, attributes);

    assertNull(this.servletRequest.getSession(false));
View Full Code Here


public class AllowedOriginsInterceptorTests extends AbstractHttpRequestTests {

  @Test
  public void originValueMatch() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
    setOrigin("http://mydomain1.com");
    OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor();
    interceptor.setAllowedOrigins(Arrays.asList("http://mydomain1.com"));
    assertTrue(interceptor.beforeHandshake(request, response, wsHandler, attributes));
    assertNotEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value());
View Full Code Here

  }

  @Test
  public void originValueNoMatch() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
    setOrigin("http://mydomain1.com");
    OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor();
    interceptor.setAllowedOrigins(Arrays.asList("http://mydomain2.com"));
    assertFalse(interceptor.beforeHandshake(request, response, wsHandler, attributes));
    assertEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value());
View Full Code Here

  }

  @Test
  public void originListMatch() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
    setOrigin("http://mydomain2.com");
    OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor();
    interceptor.setAllowedOrigins(Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com"));
    assertTrue(interceptor.beforeHandshake(request, response, wsHandler, attributes));
    assertNotEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value());
View Full Code Here

  }

  @Test
  public void originListNoMatch() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
    setOrigin("http://mydomain4.com");
    OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor();
    interceptor.setAllowedOrigins(Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com"));
    assertFalse(interceptor.beforeHandshake(request, response, wsHandler, attributes));
    assertEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value());
View Full Code Here

  }

  @Test
  public void noOriginNoMatchWithNullHostileCollection() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
    Set<String> allowedOrigins = new ConcurrentSkipListSet<String>();
    allowedOrigins.add("http://mydomain1.com");
    OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor();
    interceptor.setAllowedOrigins(allowedOrigins);
    assertFalse(interceptor.beforeHandshake(request, response, wsHandler, attributes));
View Full Code Here

  }

  @Test
   public void noOriginNoMatch() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
    OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor();
    assertFalse(interceptor.beforeHandshake(request, response, wsHandler, attributes));
    assertEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value());
  }
View Full Code Here

  }

  @Test
  public void delegateMessagesWithErrorAndConnectionClosing() throws Exception {

    WebSocketHandler wsHandler = new ExceptionWebSocketHandlerDecorator(this.webSocketHandler);
    TestSockJsSession sockJsSession = new TestSockJsSession("1", this.sockJsConfig,
        wsHandler, Collections.<String, Object>emptyMap());

    String msg1 = "message 1";
    String msg2 = "message 2";
View Full Code Here

    handleRequestAndExpectFailure();
  }

  @Test(expected=IllegalArgumentException.class)
  public void readMessagesNoSession() throws Exception {
    WebSocketHandler webSocketHandler = mock(WebSocketHandler.class);
    new XhrReceivingTransportHandler().handleRequest(this.request, this.response, webSocketHandler, null);
  }
View Full Code Here

    StubSockJsServiceConfig sockJsConfig = new StubSockJsServiceConfig();

    this.servletRequest.setContent("[\"x\"]".getBytes("UTF-8"));

    WebSocketHandler wsHandler = mock(WebSocketHandler.class);
    TestHttpSockJsSession session = new TestHttpSockJsSession("1", sockJsConfig, wsHandler, null);
    session.delegateConnectionEstablished();

    willThrow(new Exception()).given(wsHandler).handleMessage(session, new TextMessage("x"));
View Full Code Here

TOP

Related Classes of org.springframework.web.socket.WebSocketHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.