简体   繁体   English

Spring Cloud Stream在消息的有效负载中测试硬编码的“Hello World”

[英]Spring Cloud Stream Test hardcoded “Hello World” in message's payload

I'm trying out Spring Cloud Stream, and when i tried to run one of the simpliest test (original test available here: https://github.com/spring-cloud/spring-cloud-stream/blob/master/spring-cloud-stream-test-support/src/test/java/org/springframework/cloud/stream/test/disable/AutoconfigurationDisabledTest.java ) 我正在尝试Spring Cloud Stream,当我尝试运行最简单的测试之一时(原始测试可用于此处: https//github.com/spring-cloud/spring-cloud-stream/blob/master/spring- cloud-stream-test-support / src / test / java / org / springframework / cloud / stream / test / disable / AutoconfigurationDisabledTest.java

Using: Java 1.8 SpringBoot 2.1.5.RELEASE spring-cloud.version: Greenwich.RELEASE 使用:Java 1.8 SpringBoot 2.1.5.RELEASE spring-cloud.version:Greenwich.RELEASE

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@DirtiesContext
public class ExampleTest {

    @Autowired
    public MessageCollector messageCollector;

    @Autowired
    public Processor processor;

    @SuppressWarnings("unchecked")
    @Test
    public void testAutoconfigurationDisabled() {
        this.processor.input().send(MessageBuilder.withPayload("empty").build());

        Message<String> response = (Message<String>) this.messageCollector.forChannel(this.processor.output()).poll();

        Assertions.assertThat(response).isNotNull();
        Assertions.assertThat(response.getPayload()).isEqualTo("Hello World");
    }
}

Test passed, but it should not. 测试通过,但不应该。 Message is sent with "empty", and that is what i would expect to receive, but received payload always is "Hello World" 消息以“空”发送,这是我期望收到的,但收到的有效负载总是“Hello World”

Please make sure you have compiled you test class after you change from "Hello world" to "". 从“Hello world”更改为“”后,请确保已编译测试类。 I ran into the occasion of test class not compiled and always get the previous result when I use maven with Intellij, and run test from maven view. 我遇到了测试类没有编译的场合,当我使用maven和Intellij时总是得到前面的结果,并从maven视图运行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM