It's not clear why the testing samples referenced by your cited answer don't help you. It doesn't matter what's in the flow; the basic idea is to send a message into the start of the flow and examine the result from the end of the flow, perhaps by replacing the final channel with a queue channel, which you can poll from your test case.
You can stop() the ultimate consumer so he doesn't grab the result.
EDIT: (in response to comments below).
You can preempt the component's output channel...
... <int:channel id="toHE"/> <int:header-enricher id="he" input-channel="toHE" output-channel="fromHE"> <int:header name="foo" value="bar"/> </int:header-enricher> <int:channel id="fromHE"/> ...
And then...
@Autowired private MessageChannel toHE; @Autowired @Qualifier("he.handler") private MessageTransformingHandler headerEnricher; @Test @DirtiesContext public void testEnricher() { PollableChannel outputChannel = new QueueChannel(); headerEnricher.setOutputChannel(outputChannel); toHE.send(MessageBuilder.withPayload("baz").build()); Message<?> out = outputChannel.receive(10000); assertNotNull(out); assertEquals("bar", out.getHeaders().get("foo")); }