File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed
main/java/org/springframework/web/socket/messaging
test/java/org/springframework/web/socket/messaging Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -469,6 +469,7 @@ private Message<?> createDisconnectMessage(WebSocketSession session) {
469469 }
470470 headerAccessor .setSessionId (session .getId ());
471471 headerAccessor .setSessionAttributes (session .getAttributes ());
472+ headerAccessor .setUser (session .getPrincipal ());
472473 return MessageBuilder .createMessage (EMPTY_PAYLOAD , headerAccessor .getMessageHeaders ());
473474 }
474475
Original file line number Diff line number Diff line change @@ -207,13 +207,7 @@ public void eventPublication() {
207207 @ Test
208208 public void eventPublicationWithExceptions () {
209209
210- ApplicationEventPublisher publisher = new ApplicationEventPublisher () {
211-
212- @ Override
213- public void publishEvent (ApplicationEvent event ) {
214- throw new IllegalStateException ();
215- }
216- };
210+ ApplicationEventPublisher publisher = mock (ApplicationEventPublisher .class );
217211
218212 UserSessionRegistry registry = new DefaultUserSessionRegistry ();
219213 this .protocolHandler .setUserSessionRegistry (registry );
@@ -244,7 +238,10 @@ public void publishEvent(ApplicationEvent event) {
244238 verify (this .channel ).send (this .messageCaptor .capture ());
245239 actual = this .messageCaptor .getValue ();
246240 assertNotNull (actual );
247- assertEquals (StompCommand .DISCONNECT , StompHeaderAccessor .wrap (actual ).getCommand ());
241+ StompHeaderAccessor accessor = StompHeaderAccessor .wrap (actual );
242+ assertEquals (StompCommand .DISCONNECT , accessor .getCommand ());
243+ assertEquals ("s1" , accessor .getSessionId ());
244+ assertEquals ("joe" , accessor .getUser ().getName ());
248245 }
249246
250247 @ Test
You can’t perform that action at this time.
0 commit comments