Add user to DISCONNECT in StompSubProtocolHandler

Issue: SPR-12215
This commit is contained in:
Rossen Stoyanchev 2014-09-18 15:06:08 -04:00
parent b1e9577680
commit 4af9851585
2 changed files with 6 additions and 8 deletions

View File

@ -469,6 +469,7 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
} }
headerAccessor.setSessionId(session.getId()); headerAccessor.setSessionId(session.getId());
headerAccessor.setSessionAttributes(session.getAttributes()); headerAccessor.setSessionAttributes(session.getAttributes());
headerAccessor.setUser(session.getPrincipal());
return MessageBuilder.createMessage(EMPTY_PAYLOAD, headerAccessor.getMessageHeaders()); return MessageBuilder.createMessage(EMPTY_PAYLOAD, headerAccessor.getMessageHeaders());
} }

View File

@ -207,13 +207,7 @@ public class StompSubProtocolHandlerTests {
@Test @Test
public void eventPublicationWithExceptions() { public void eventPublicationWithExceptions() {
ApplicationEventPublisher publisher = new ApplicationEventPublisher() { ApplicationEventPublisher publisher = mock(ApplicationEventPublisher.class);
@Override
public void publishEvent(ApplicationEvent event) {
throw new IllegalStateException();
}
};
UserSessionRegistry registry = new DefaultUserSessionRegistry(); UserSessionRegistry registry = new DefaultUserSessionRegistry();
this.protocolHandler.setUserSessionRegistry(registry); this.protocolHandler.setUserSessionRegistry(registry);
@ -244,7 +238,10 @@ public class StompSubProtocolHandlerTests {
verify(this.channel).send(this.messageCaptor.capture()); verify(this.channel).send(this.messageCaptor.capture());
actual = this.messageCaptor.getValue(); actual = this.messageCaptor.getValue();
assertNotNull(actual); assertNotNull(actual);
assertEquals(StompCommand.DISCONNECT, StompHeaderAccessor.wrap(actual).getCommand()); StompHeaderAccessor accessor = StompHeaderAccessor.wrap(actual);
assertEquals(StompCommand.DISCONNECT, accessor.getCommand());
assertEquals("s1", accessor.getSessionId());
assertEquals("joe", accessor.getUser().getName());
} }
@Test @Test