Search in sources :

Example 1 with StubMessageChannel

use of org.springframework.messaging.StubMessageChannel in project spring-framework by spring-projects.

the class GenericMessagingTemplateTests method setup.

@BeforeEach
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();
}
Also used : ThreadPoolTaskExecutor(org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor) StubMessageChannel(org.springframework.messaging.StubMessageChannel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with StubMessageChannel

use of org.springframework.messaging.StubMessageChannel in project spring-framework by spring-projects.

the class StompBrokerRelayMessageHandlerTests method setup.

@BeforeEach
void setup() {
    this.outboundChannel = new StubMessageChannel();
    this.brokerRelay = new StompBrokerRelayMessageHandler(new StubMessageChannel(), this.outboundChannel, new StubMessageChannel(), Collections.singletonList("/topic")) {

        @Override
        protected void startInternal() {
            // Force this, since we'll never actually connect
            publishBrokerAvailableEvent();
            super.startInternal();
        }
    };
    this.tcpClient = new StubTcpOperations();
    this.brokerRelay.setTcpClient(this.tcpClient);
    this.brokerRelay.setTaskScheduler(mock(TaskScheduler.class));
}
Also used : StubMessageChannel(org.springframework.messaging.StubMessageChannel) TaskScheduler(org.springframework.scheduling.TaskScheduler) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with StubMessageChannel

use of org.springframework.messaging.StubMessageChannel in project spring-framework by spring-projects.

the class StompBrokerRelayRegistrationTests method test.

@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());
    assertThat(StringUtils.toStringArray(handler.getDestinationPrefixes())).isEqualTo(prefixes);
    assertThat(handler.getClientLogin()).isEqualTo("clientlogin");
    assertThat(handler.getClientPasscode()).isEqualTo("clientpasscode");
    assertThat(handler.getSystemLogin()).isEqualTo("syslogin");
    assertThat(handler.getSystemPasscode()).isEqualTo("syspasscode");
    assertThat(handler.getSystemHeartbeatReceiveInterval()).isEqualTo(123);
    assertThat(handler.getSystemHeartbeatSendInterval()).isEqualTo(456);
    assertThat(handler.getVirtualHost()).isEqualTo("example.org");
}
Also used : MessageChannel(org.springframework.messaging.MessageChannel) StubMessageChannel(org.springframework.messaging.StubMessageChannel) StompBrokerRelayMessageHandler(org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler) StubMessageChannel(org.springframework.messaging.StubMessageChannel) SubscribableChannel(org.springframework.messaging.SubscribableChannel) Test(org.junit.jupiter.api.Test)

Example 4 with StubMessageChannel

use of org.springframework.messaging.StubMessageChannel in project spring-framework by spring-projects.

the class StompBrokerRelayMessageHandlerIntegrationTests method createAndStartRelay.

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);
}
Also used : StubMessageChannel(org.springframework.messaging.StubMessageChannel)

Example 5 with StubMessageChannel

use of org.springframework.messaging.StubMessageChannel in project spring-framework by spring-projects.

the class SimpMessagingTemplateTests method setup.

@BeforeEach
public void setup() {
    this.messageChannel = new StubMessageChannel();
    this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel);
}
Also used : StubMessageChannel(org.springframework.messaging.StubMessageChannel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

StubMessageChannel (org.springframework.messaging.StubMessageChannel)5 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Test (org.junit.jupiter.api.Test)1 MessageChannel (org.springframework.messaging.MessageChannel)1 SubscribableChannel (org.springframework.messaging.SubscribableChannel)1 StompBrokerRelayMessageHandler (org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler)1 TaskScheduler (org.springframework.scheduling.TaskScheduler)1 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)1