StompSession supports custom headers for UNSUBSCRIBE
Issue: SPR-15131
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -471,6 +471,34 @@ public class DefaultStompSessionTests {
|
||||
assertEquals(subscription.getSubscriptionId(), stompHeaders.getId());
|
||||
}
|
||||
|
||||
@Test // SPR-15131
|
||||
public void unsubscribeWithCustomHeader() throws Exception {
|
||||
this.session.afterConnected(this.connection);
|
||||
assertTrue(this.session.isConnected());
|
||||
|
||||
String headerName = "durable-subscription-name";
|
||||
String headerValue = "123";
|
||||
|
||||
StompHeaders subscribeHeaders = new StompHeaders();
|
||||
subscribeHeaders.setDestination("/topic/foo");
|
||||
subscribeHeaders.set(headerName, headerValue);
|
||||
StompFrameHandler frameHandler = mock(StompFrameHandler.class);
|
||||
Subscription subscription = this.session.subscribe(subscribeHeaders, frameHandler);
|
||||
|
||||
StompHeaders unsubscribeHeaders = new StompHeaders();
|
||||
unsubscribeHeaders.set(headerName, subscription.getSubscriptionHeaders().getFirst(headerName));
|
||||
subscription.unsubscribe(unsubscribeHeaders);
|
||||
|
||||
Message<byte[]> message = this.messageCaptor.getValue();
|
||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
assertEquals(StompCommand.UNSUBSCRIBE, accessor.getCommand());
|
||||
|
||||
StompHeaders stompHeaders = StompHeaders.readOnlyStompHeaders(accessor.getNativeHeaders());
|
||||
assertEquals(stompHeaders.toString(), 2, stompHeaders.size());
|
||||
assertEquals(subscription.getSubscriptionId(), stompHeaders.getId());
|
||||
assertEquals(headerValue, stompHeaders.getFirst(headerName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ack() throws Exception {
|
||||
this.session.afterConnected(this.connection);
|
||||
|
||||
Reference in New Issue
Block a user