类org.springframework.messaging.StubMessageChannel源码实例Demo

下面列出了怎么用org.springframework.messaging.StubMessageChannel的API类实例代码及写法,或者点击链接到github查看源代码。

@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);
}
 
@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);
}
 
@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);
}
 
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);
}
 
@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);
}
 
@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());
}
 
@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();
}
 
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);
}
 
@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);
}
 
@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());
}
 
@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();
}
 
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);
}
 
@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);
}
 
@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());
}
 
@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();
}
 
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
}
 
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
}
 
@Before
public void setup() {
	this.messageChannel = new StubMessageChannel();
	this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
}
 
 类方法
 同包方法