Java Code Examples for org.springframework.messaging.core.MessageSendingOperations

The following examples show how to use org.springframework.messaging.core.MessageSendingOperations. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testHeadersPassedToMessagingTemplate() throws Exception {
	String sessionId = "sess1";
	String subscriptionId = "subs1";
	String destination = "/dest";
	Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null);

	MessageSendingOperations messagingTemplate = Mockito.mock(MessageSendingOperations.class);
	SubscriptionMethodReturnValueHandler handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);

	handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage);

	ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class);
	verify(messagingTemplate).convertAndSend(eq("/dest"), eq(PAYLOAD), captor.capture());

	SimpMessageHeaderAccessor headerAccessor =
			MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class);

	assertNotNull(headerAccessor);
	assertTrue(headerAccessor.isMutable());
	assertEquals(sessionId, headerAccessor.getSessionId());
	assertEquals(subscriptionId, headerAccessor.getSubscriptionId());
	assertEquals(this.subscribeEventReturnType, headerAccessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER));
}
 
Example 2
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testHeadersPassedToMessagingTemplate() throws Exception {
	String sessionId = "sess1";
	String subscriptionId = "subs1";
	String destination = "/dest";
	Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null);

	MessageSendingOperations messagingTemplate = Mockito.mock(MessageSendingOperations.class);
	SubscriptionMethodReturnValueHandler handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);

	handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage);

	ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class);
	verify(messagingTemplate).convertAndSend(eq("/dest"), eq(PAYLOAD), captor.capture());

	SimpMessageHeaderAccessor headerAccessor =
			MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class);

	assertNotNull(headerAccessor);
	assertTrue(headerAccessor.isMutable());
	assertEquals(sessionId, headerAccessor.getSessionId());
	assertEquals(subscriptionId, headerAccessor.getSubscriptionId());
	assertEquals(this.subscribeEventReturnType, headerAccessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER));
}
 
Example 3
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testHeadersPassedToMessagingTemplate() throws Exception {
	String sessionId = "sess1";
	String subscriptionId = "subs1";
	String destination = "/dest";
	Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null);

	MessageSendingOperations messagingTemplate = Mockito.mock(MessageSendingOperations.class);
	SubscriptionMethodReturnValueHandler handler = new SubscriptionMethodReturnValueHandler(messagingTemplate);

	handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage);

	ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class);
	verify(messagingTemplate).convertAndSend(eq("/dest"), eq(PAYLOAD), captor.capture());

	SimpMessageHeaderAccessor headerAccessor =
			MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class);

	assertNotNull(headerAccessor);
	assertTrue(headerAccessor.isMutable());
	assertEquals(sessionId, headerAccessor.getSessionId());
	assertEquals(subscriptionId, headerAccessor.getSubscriptionId());
	assertEquals(this.subscribeEventReturnType, headerAccessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER));
}
 
Example 4
public BroadcastHandler(MessageSendingOperations<String> template, String destination) {
	this.messagingTemplate = template;
	this.broadcastDestination = destination;
}
 
Example 5
public BroadcastHandler(MessageSendingOperations<String> template, String destination) {
	this.messagingTemplate = template;
	this.broadcastDestination = destination;
}
 
Example 6
public BroadcastHandler(MessageSendingOperations<String> template, String destination) {
	this.messagingTemplate = template;
	this.broadcastDestination = destination;
}
 
Example 7
Source Project: bearchoke   Source File: QuoteServiceImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public QuoteServiceImpl(MessageSendingOperations<String> messagingTemplate) {
	this.messagingTemplate = messagingTemplate;
}
 
Example 8
Source Project: bearchoke   Source File: MockServerConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean(name = "messageSendingOperations")
public MessageSendingOperations messageSendingOperations() {
    return mock(MessageSendingOperations.class);
}
 
Example 9
Source Project: spring4ws-demos   Source File: QuoteService.java    License: Apache License 2.0 4 votes vote down vote up
@Autowired
public QuoteService(MessageSendingOperations<String> messagingTemplate) {
	this.messagingTemplate = messagingTemplate;
}
 
Example 10
/**
 * Construct a new SubscriptionMethodReturnValueHandler.
 * @param template a messaging template to send messages to,
 * most likely the "clientOutboundChannel" (must not be {@code null})
 */
public SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> template) {
	Assert.notNull(template, "messagingTemplate must not be null");
	this.messagingTemplate = template;
}
 
Example 11
/**
 * Return the messaging template used to send resolved messages to the
 * broker channel.
 */
public MessageSendingOperations<String> getBrokerMessagingTemplate() {
	return this.messagingTemplate;
}
 
Example 12
/**
 * Construct a new SubscriptionMethodReturnValueHandler.
 * @param template a messaging template to send messages to,
 * most likely the "clientOutboundChannel" (must not be {@code null})
 */
public SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> template) {
	Assert.notNull(template, "messagingTemplate must not be null");
	this.messagingTemplate = template;
}
 
Example 13
/**
 * Return the messaging template used to send resolved messages to the
 * broker channel.
 */
public MessageSendingOperations<String> getBrokerMessagingTemplate() {
	return this.messagingTemplate;
}
 
Example 14
/**
 * Construct a new SubscriptionMethodReturnValueHandler.
 * @param messagingTemplate a messaging template to send messages to,
 * most likely the "clientOutboundChannel" (must not be {@code null})
 */
public SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> messagingTemplate) {
	Assert.notNull(messagingTemplate, "messagingTemplate must not be null");
	this.messagingTemplate = messagingTemplate;
}
 
Example 15
/**
 * Return the messaging template used to send resolved messages to the
 * broker channel.
 */
public MessageSendingOperations<String> getBrokerMessagingTemplate() {
	return this.messagingTemplate;
}