Search in sources :

Example 31 with TestPrincipal

use of org.springframework.core.testfixture.security.TestPrincipal in project spring-framework by spring-projects.

the class SimpMessageHeaderAccessorTests method getLogMessageWithValuesSet.

@Test
public void getLogMessageWithValuesSet() {
    SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
    accessor.setDestination("/destination");
    accessor.setSubscriptionId("subscription");
    accessor.setSessionId("session");
    accessor.setUser(new TestPrincipal("user"));
    accessor.setSessionAttributes(Collections.<String, Object>singletonMap("key", "value"));
    assertThat(accessor.getShortLogMessage("p")).isEqualTo(("MESSAGE destination=/destination subscriptionId=subscription " + "session=session user=user attributes[1] payload=p"));
}
Also used : TestPrincipal(org.springframework.core.testfixture.security.TestPrincipal) Test(org.junit.jupiter.api.Test)

Aggregations

TestPrincipal (org.springframework.core.testfixture.security.TestPrincipal)31 Test (org.junit.jupiter.api.Test)27 Message (org.springframework.messaging.Message)4 SimpUser (org.springframework.messaging.simp.user.SimpUser)4 MessageHeaders (org.springframework.messaging.MessageHeaders)2 SimpMessageHeaderAccessor (org.springframework.messaging.simp.SimpMessageHeaderAccessor)2 TextMessage (org.springframework.web.socket.TextMessage)2 Session (jakarta.websocket.Session)1 HashSet (java.util.HashSet)1 Session (org.eclipse.jetty.websocket.api.Session)1 UpgradeRequest (org.eclipse.jetty.websocket.api.UpgradeRequest)1 UpgradeResponse (org.eclipse.jetty.websocket.api.UpgradeResponse)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 MessageChannel (org.springframework.messaging.MessageChannel)1 SimpSubscription (org.springframework.messaging.simp.user.SimpSubscription)1 BinaryMessage (org.springframework.web.socket.BinaryMessage)1 CloseStatus (org.springframework.web.socket.CloseStatus)1 WebSocketMessage (org.springframework.web.socket.WebSocketMessage)1 TestWebSocketSession (org.springframework.web.socket.handler.TestWebSocketSession)1