0
votes

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)

Using: 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"

1
I am not sure I understand. I just executed your test which resulted in the test failure org.junit.ComparisonFailure: expected:<"[Hello] world"> but was:<"[empty] world"> - Oleg Zhurakousky
Yes, test failure is what i would expect, but i run it once again (after rebuild), but with compiler screenshot It still shows "Hello World" as payload on polled message - Patryk Wargacki
All I am saying is that based on your description I can not reproduce it - Oleg Zhurakousky
Which binder are you using and what do your application properties look like? - Stuck
There is no binder for that test case. I mean it is an internal test binder. . . This is clearly some IDE related issue (e.g., file wasn't saved, not compiled etc. . .) - Oleg Zhurakousky

1 Answers

0
votes

Please make sure you have compiled you test class after you change from "Hello world" to "". 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.