org.springframework.messaging.core.MessageSendingOperations Java Examples

The following examples show how to use org.springframework.messaging.core.MessageSendingOperations. 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
Source File: SubscriptionMethodReturnValueHandlerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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
Source File: SubscriptionMethodReturnValueHandlerTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@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
Source File: SubscriptionMethodReturnValueHandlerTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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
Source File: UserDestinationMessageHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public BroadcastHandler(MessageSendingOperations<String> template, String destination) {
	this.messagingTemplate = template;
	this.broadcastDestination = destination;
}
 
Example #5
Source File: UserDestinationMessageHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
public BroadcastHandler(MessageSendingOperations<String> template, String destination) {
	this.messagingTemplate = template;
	this.broadcastDestination = destination;
}
 
Example #6
Source File: UserDestinationMessageHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public BroadcastHandler(MessageSendingOperations<String> template, String destination) {
	this.messagingTemplate = template;
	this.broadcastDestination = destination;
}
 
Example #7
Source File: QuoteServiceImpl.java    From bearchoke with Apache License 2.0 4 votes vote down vote up
@Autowired
public QuoteServiceImpl(MessageSendingOperations<String> messagingTemplate) {
	this.messagingTemplate = messagingTemplate;
}
 
Example #8
Source File: MockServerConfig.java    From bearchoke with Apache License 2.0 4 votes vote down vote up
@Bean(name = "messageSendingOperations")
public MessageSendingOperations messageSendingOperations() {
    return mock(MessageSendingOperations.class);
}
 
Example #9
Source File: QuoteService.java    From spring4ws-demos with Apache License 2.0 4 votes vote down vote up
@Autowired
public QuoteService(MessageSendingOperations<String> messagingTemplate) {
	this.messagingTemplate = messagingTemplate;
}
 
Example #10
Source File: SubscriptionMethodReturnValueHandler.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * 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
Source File: UserDestinationMessageHandler.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Return the messaging template used to send resolved messages to the
 * broker channel.
 */
public MessageSendingOperations<String> getBrokerMessagingTemplate() {
	return this.messagingTemplate;
}
 
Example #12
Source File: SubscriptionMethodReturnValueHandler.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * 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
Source File: UserDestinationMessageHandler.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Return the messaging template used to send resolved messages to the
 * broker channel.
 */
public MessageSendingOperations<String> getBrokerMessagingTemplate() {
	return this.messagingTemplate;
}
 
Example #14
Source File: SubscriptionMethodReturnValueHandler.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * 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
Source File: UserDestinationMessageHandler.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Return the messaging template used to send resolved messages to the
 * broker channel.
 */
public MessageSendingOperations<String> getBrokerMessagingTemplate() {
	return this.messagingTemplate;
}