|
1 | 1 | /* |
2 | | - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2022 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -223,6 +223,30 @@ void systemSubscription() { |
223 | 223 | assertThat(captor.getValue()).isSameAs(message); |
224 | 224 | } |
225 | 225 |
|
| 226 | + @Test |
| 227 | + void alreadyConnected() { |
| 228 | + |
| 229 | + this.brokerRelay.start(); |
| 230 | + |
| 231 | + Message<byte[]> connect = connectMessage("sess1", "joe"); |
| 232 | + this.brokerRelay.handleMessage(connect); |
| 233 | + |
| 234 | + assertThat(this.tcpClient.getSentMessages().size()).isEqualTo(2); |
| 235 | + |
| 236 | + StompHeaderAccessor headers1 = this.tcpClient.getSentHeaders(0); |
| 237 | + assertThat(headers1.getCommand()).isEqualTo(StompCommand.CONNECT); |
| 238 | + assertThat(headers1.getSessionId()).isEqualTo(StompBrokerRelayMessageHandler.SYSTEM_SESSION_ID); |
| 239 | + |
| 240 | + StompHeaderAccessor headers2 = this.tcpClient.getSentHeaders(1); |
| 241 | + assertThat(headers2.getCommand()).isEqualTo(StompCommand.CONNECT); |
| 242 | + assertThat(headers2.getSessionId()).isEqualTo("sess1"); |
| 243 | + |
| 244 | + this.brokerRelay.handleMessage(connect); |
| 245 | + |
| 246 | + assertThat(this.tcpClient.getSentMessages().size()).isEqualTo(2); |
| 247 | + assertThat(this.outboundChannel.getMessages()).isEmpty(); |
| 248 | + } |
| 249 | + |
226 | 250 | private Message<byte[]> connectMessage(String sessionId, String user) { |
227 | 251 | StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.CONNECT); |
228 | 252 | headers.setSessionId(sessionId); |
|
0 commit comments