Java Code Examples for org.springframework.messaging.simp.SimpMessageHeaderAccessor#setSessionAttributes()
The following examples show how to use
org.springframework.messaging.simp.SimpMessageHeaderAccessor#setSessionAttributes() .
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: SimpAnnotationMethodMessageHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void simpScope() { Map<String, Object> sessionAttributes = new ConcurrentHashMap<>(); sessionAttributes.put("name", "value"); SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(); headers.setSessionId("session1"); headers.setSessionAttributes(sessionAttributes); headers.setDestination("/pre/scope"); Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build(); this.messageHandler.registerHandler(this.testController); this.messageHandler.handleMessage(message); assertEquals("scope", this.testController.method); }
Example 2
Source File: SimpAnnotationMethodMessageHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
private Message<?> createMessage(SimpMessageType messageType, String destination, Map<String, Object> headers) { SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create(messageType); accessor.setSessionId("session1"); accessor.setSessionAttributes(new HashMap<>()); accessor.setDestination(destination); if (headers != null) { for (Map.Entry<String, Object> entry : headers.entrySet()) { accessor.setHeader(entry.getKey(), entry.getValue()); } } return MessageBuilder.withPayload(new byte[0]).setHeaders(accessor).build(); }
Example 3
Source File: WebSocketAnnotationMethodMessageHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void globalException() throws Exception { SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(); headers.setSessionId("session1"); headers.setSessionAttributes(new ConcurrentHashMap<>()); headers.setDestination("/exception"); Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build(); this.messageHandler.handleMessage(message); TestControllerAdvice controllerAdvice = this.applicationContext.getBean(TestControllerAdvice.class); assertTrue(controllerAdvice.isExceptionHandled()); }
Example 4
Source File: SimpAnnotationMethodMessageHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void simpScope() { Map<String, Object> sessionAttributes = new ConcurrentHashMap<>(); sessionAttributes.put("name", "value"); SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(); headers.setSessionId("session1"); headers.setSessionAttributes(sessionAttributes); headers.setDestination("/pre/scope"); Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build(); this.messageHandler.registerHandler(this.testController); this.messageHandler.handleMessage(message); assertEquals("scope", this.testController.method); }
Example 5
Source File: SimpAnnotationMethodMessageHandlerTests.java From java-technology-stack with MIT License | 5 votes |
private Message<?> createMessage(SimpMessageType messageType, String destination, Map<String, Object> headers) { SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create(messageType); accessor.setSessionId("session1"); accessor.setSessionAttributes(new HashMap<>()); accessor.setDestination(destination); if (headers != null) { for (Map.Entry<String, Object> entry : headers.entrySet()) { accessor.setHeader(entry.getKey(), entry.getValue()); } } return MessageBuilder.withPayload(new byte[0]).setHeaders(accessor).build(); }
Example 6
Source File: WebSocketAnnotationMethodMessageHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void globalException() throws Exception { SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(); headers.setSessionId("session1"); headers.setSessionAttributes(new ConcurrentHashMap<>()); headers.setDestination("/exception"); Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build(); this.messageHandler.handleMessage(message); TestControllerAdvice controllerAdvice = this.applicationContext.getBean(TestControllerAdvice.class); assertTrue(controllerAdvice.isExceptionHandled()); }
Example 7
Source File: SimpAnnotationMethodMessageHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void simpScope() { Map<String, Object> sessionAttributes = new ConcurrentHashMap<>(); sessionAttributes.put("name", "value"); SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(); headers.setSessionId("session1"); headers.setSessionAttributes(sessionAttributes); headers.setDestination("/pre/scope"); Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build(); this.messageHandler.registerHandler(this.testController); this.messageHandler.handleMessage(message); assertEquals("scope", this.testController.method); }
Example 8
Source File: SimpAnnotationMethodMessageHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
private Message<?> createMessage(String destination, Map<String, Object> headers) { SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create(); accessor.setSessionId("session1"); accessor.setSessionAttributes(new HashMap<>()); accessor.setDestination(destination); if (headers != null) { for (Map.Entry<String, Object> entry : headers.entrySet()) { accessor.setHeader(entry.getKey(), entry.getValue()); } } return MessageBuilder.withPayload(new byte[0]).setHeaders(accessor).build(); }
Example 9
Source File: WebSocketAnnotationMethodMessageHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void globalException() throws Exception { SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.create(); headers.setSessionId("session1"); headers.setSessionAttributes(new ConcurrentHashMap<>()); headers.setDestination("/exception"); Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build(); this.messageHandler.handleMessage(message); TestControllerAdvice controllerAdvice = this.applicationContext.getBean(TestControllerAdvice.class); assertTrue(controllerAdvice.isExceptionHandled()); }