org.springframework.messaging.StubMessageChannel Java Examples

The following examples show how to use org.springframework.messaging.StubMessageChannel. 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: StompBrokerRelayMessageHandlerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Before
public void setup() {

	this.outboundChannel = new StubMessageChannel();

	this.brokerRelay = new StompBrokerRelayMessageHandler(new StubMessageChannel(),
			this.outboundChannel, new StubMessageChannel(), Arrays.asList("/topic")) {

		@Override
		protected void startInternal() {
			publishBrokerAvailableEvent(); // Force this, since we'll never actually connect
			super.startInternal();
		}
	};

	this.tcpClient = new StubTcpOperations();
	this.brokerRelay.setTcpClient(this.tcpClient);
}
 
Example #2
Source File: StompBrokerRelayMessageHandlerTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {

	this.outboundChannel = new StubMessageChannel();

	this.brokerRelay = new StompBrokerRelayMessageHandler(new StubMessageChannel(),
			this.outboundChannel, new StubMessageChannel(), Arrays.asList("/topic")) {

		@Override
		protected void startInternal() {
			publishBrokerAvailableEvent(); // Force this, since we'll never actually connect
			super.startInternal();
		}
	};

	this.tcpClient = new StubTcpOperations();
	this.brokerRelay.setTcpClient(this.tcpClient);
}
 
Example #3
Source File: StompBrokerRelayMessageHandlerTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Before
public void setup() {

	this.outboundChannel = new StubMessageChannel();

	this.brokerRelay = new StompBrokerRelayMessageHandler(new StubMessageChannel(),
			this.outboundChannel, new StubMessageChannel(), Arrays.asList("/topic")) {

		@Override
		protected void startInternal() {
			publishBrokerAvailableEvent(); // Force this, since we'll never actually connect
			super.startInternal();
		}
	};

	this.tcpClient = new StubTcpOperations();
	this.brokerRelay.setTcpClient(this.tcpClient);
}
 
Example #4
Source File: GenericMessagingTemplateTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.template = new GenericMessagingTemplate();
	this.template.setDefaultDestination(this.messageChannel);
	this.template.setDestinationResolver(new TestDestinationResolver());
	this.executor = new ThreadPoolTaskExecutor();
	this.executor.afterPropertiesSet();
}
 
Example #5
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void createAndStartRelay() throws InterruptedException {
	StubMessageChannel channel = new StubMessageChannel();
	List<String> prefixes = Arrays.asList("/queue/", "/topic/");
	this.relay = new StompBrokerRelayMessageHandler(channel, this.responseChannel, channel, prefixes);
	this.relay.setRelayPort(this.port);
	this.relay.setApplicationEventPublisher(this.eventPublisher);
	this.relay.setSystemHeartbeatReceiveInterval(0);
	this.relay.setSystemHeartbeatSendInterval(0);
	this.relay.setPreservePublishOrder(true);

	this.relay.start();
	this.eventPublisher.expectBrokerAvailabilityEvent(true);
}
 
Example #6
Source File: StompBrokerRelayRegistrationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {

	SubscribableChannel inChannel = new StubMessageChannel();
	MessageChannel outChannel = new StubMessageChannel();
	String[] prefixes = new String[] { "/foo", "/bar" };

	StompBrokerRelayRegistration registration = new StompBrokerRelayRegistration(inChannel, outChannel, prefixes);
	registration.setClientLogin("clientlogin");
	registration.setClientPasscode("clientpasscode");
	registration.setSystemLogin("syslogin");
	registration.setSystemPasscode("syspasscode");
	registration.setSystemHeartbeatReceiveInterval(123);
	registration.setSystemHeartbeatSendInterval(456);
	registration.setVirtualHost("example.org");

	StompBrokerRelayMessageHandler handler = registration.getMessageHandler(new StubMessageChannel());

	assertArrayEquals(prefixes, handler.getDestinationPrefixes().toArray(new String[2]));
	assertEquals("clientlogin", handler.getClientLogin());
	assertEquals("clientpasscode", handler.getClientPasscode());
	assertEquals("syslogin", handler.getSystemLogin());
	assertEquals("syspasscode", handler.getSystemPasscode());
	assertEquals(123, handler.getSystemHeartbeatReceiveInterval());
	assertEquals(456, handler.getSystemHeartbeatSendInterval());
	assertEquals("example.org", handler.getVirtualHost());
}
 
Example #7
Source File: UserDestinationMessageHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	this.registry = mock(SimpUserRegistry.class);
	this.brokerChannel = mock(SubscribableChannel.class);
	UserDestinationResolver resolver = new DefaultUserDestinationResolver(this.registry);
	this.handler = new UserDestinationMessageHandler(new StubMessageChannel(), this.brokerChannel, resolver);
}
 
Example #8
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void createAndStartRelay() throws InterruptedException {
	this.relay = new StompBrokerRelayMessageHandler(new StubMessageChannel(),
			this.responseChannel, new StubMessageChannel(), Arrays.asList("/queue/", "/topic/"));
	this.relay.setRelayPort(this.port);
	this.relay.setApplicationEventPublisher(this.eventPublisher);
	this.relay.setSystemHeartbeatReceiveInterval(0);
	this.relay.setSystemHeartbeatSendInterval(0);

	this.relay.start();
	this.eventPublisher.expectBrokerAvailabilityEvent(true);
}
 
Example #9
Source File: GenericMessagingTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.template = new GenericMessagingTemplate();
	this.template.setDefaultDestination(this.messageChannel);
	this.template.setDestinationResolver(new TestDestinationResolver());
	this.executor = new ThreadPoolTaskExecutor();
	this.executor.afterPropertiesSet();
}
 
Example #10
Source File: StompBrokerRelayRegistrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void test() {

	SubscribableChannel inChannel = new StubMessageChannel();
	MessageChannel outChannel = new StubMessageChannel();
	String[] prefixes = new String[] { "/foo", "/bar" };

	StompBrokerRelayRegistration registration = new StompBrokerRelayRegistration(inChannel, outChannel, prefixes);
	registration.setClientLogin("clientlogin");
	registration.setClientPasscode("clientpasscode");
	registration.setSystemLogin("syslogin");
	registration.setSystemPasscode("syspasscode");
	registration.setSystemHeartbeatReceiveInterval(123);
	registration.setSystemHeartbeatSendInterval(456);
	registration.setVirtualHost("example.org");

	StompBrokerRelayMessageHandler handler = registration.getMessageHandler(new StubMessageChannel());

	assertArrayEquals(prefixes, StringUtils.toStringArray(handler.getDestinationPrefixes()));
	assertEquals("clientlogin", handler.getClientLogin());
	assertEquals("clientpasscode", handler.getClientPasscode());
	assertEquals("syslogin", handler.getSystemLogin());
	assertEquals("syspasscode", handler.getSystemPasscode());
	assertEquals(123, handler.getSystemHeartbeatReceiveInterval());
	assertEquals(456, handler.getSystemHeartbeatSendInterval());
	assertEquals("example.org", handler.getVirtualHost());
}
 
Example #11
Source File: UserDestinationMessageHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Before
public void setup() {
	this.registry = mock(SimpUserRegistry.class);
	this.brokerChannel = mock(SubscribableChannel.class);
	UserDestinationResolver resolver = new DefaultUserDestinationResolver(this.registry);
	this.handler = new UserDestinationMessageHandler(new StubMessageChannel(), this.brokerChannel, resolver);
}
 
Example #12
Source File: StompBrokerRelayMessageHandlerIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void createAndStartRelay() throws InterruptedException {
	StubMessageChannel channel = new StubMessageChannel();
	List<String> prefixes = Arrays.asList("/queue/", "/topic/");
	this.relay = new StompBrokerRelayMessageHandler(channel, this.responseChannel, channel, prefixes);
	this.relay.setRelayPort(this.port);
	this.relay.setApplicationEventPublisher(this.eventPublisher);
	this.relay.setSystemHeartbeatReceiveInterval(0);
	this.relay.setSystemHeartbeatSendInterval(0);
	this.relay.setPreservePublishOrder(true);

	this.relay.start();
	this.eventPublisher.expectBrokerAvailabilityEvent(true);
}
 
Example #13
Source File: GenericMessagingTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.template = new GenericMessagingTemplate();
	this.template.setDefaultDestination(this.messageChannel);
	this.template.setDestinationResolver(new TestDestinationResolver());
	this.executor = new ThreadPoolTaskExecutor();
	this.executor.afterPropertiesSet();
}
 
Example #14
Source File: StompBrokerRelayRegistrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void test() {

	SubscribableChannel inChannel = new StubMessageChannel();
	MessageChannel outChannel = new StubMessageChannel();
	String[] prefixes = new String[] { "/foo", "/bar" };

	StompBrokerRelayRegistration registration = new StompBrokerRelayRegistration(inChannel, outChannel, prefixes);
	registration.setClientLogin("clientlogin");
	registration.setClientPasscode("clientpasscode");
	registration.setSystemLogin("syslogin");
	registration.setSystemPasscode("syspasscode");
	registration.setSystemHeartbeatReceiveInterval(123);
	registration.setSystemHeartbeatSendInterval(456);
	registration.setVirtualHost("example.org");

	StompBrokerRelayMessageHandler handler = registration.getMessageHandler(new StubMessageChannel());

	assertArrayEquals(prefixes, StringUtils.toStringArray(handler.getDestinationPrefixes()));
	assertEquals("clientlogin", handler.getClientLogin());
	assertEquals("clientpasscode", handler.getClientPasscode());
	assertEquals("syslogin", handler.getSystemLogin());
	assertEquals("syspasscode", handler.getSystemPasscode());
	assertEquals(123, handler.getSystemHeartbeatReceiveInterval());
	assertEquals(456, handler.getSystemHeartbeatSendInterval());
	assertEquals("example.org", handler.getVirtualHost());
}
 
Example #15
Source File: UserDestinationMessageHandlerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Before
public void setup() {
	this.registry = mock(SimpUserRegistry.class);
	this.brokerChannel = mock(SubscribableChannel.class);
	UserDestinationResolver resolver = new DefaultUserDestinationResolver(this.registry);
	this.handler = new UserDestinationMessageHandler(new StubMessageChannel(), this.brokerChannel, resolver);
}
 
Example #16
Source File: SimpMessagingTemplateTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
}
 
Example #17
Source File: SimpMessagingTemplateTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
}
 
Example #18
Source File: SimpMessagingTemplateTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
}