簡體   English   中英

在我的測試中如何從Spring Cloud Stream獲取通道對象

[英]How get channel object from spring cloud stream in my test

我已經定義了下面的TestChannel接口

public interface TestChannel {
    String CHANNEL_NAME = "test.channel";

    @Input(value = CHANNEL_NAME)
    SubscribableChannel channel();
}

我嘗試在測試中自動連線此頻道。

@SpringBootTest
public class TestChannelHandlerTest extends BaseTest {

    @Autowired
    private TestChannel testChannel;

    @Test
    public void someTest() {
    ...
    }
}

但是TestChannel bean。 我的問題是:如何為所有頻道自動接線。

@Qualifier("test.channel")添加到@Autowired

如果名稱為testChanneltestChannel

您還需要在某個地方使用@EnableBinding(TestChannel.class)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM