davsclaus commented on code in PR #28082:
URL: https://github.com/apache/camel/pull/28082#discussion_r4311979346
##########
components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerUnsupportedCharsetTest.java:
##########
@@ -69,6 +62,20 @@ public void configure() {
headers.put("Content-Type", "text/plain; charset=XXX");
template.sendBodyAndHeaders(jones1.uriPrefix(Protocol.smtp) +
"&ignoreUnsupportedCharset=true", "Bye World", headers);
+ // Set up expectations and add the consumer route only after both
messages are in the
+ // mailbox, so the POP3 consumer can reliably fetch both on its very
first poll.
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedBodiesReceivedInAnyOrder("Hello World\r\n", "Bye
World\r\n");
+ mock.allMessages().header("Content-Type").isEqualTo("text/plain");
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from(jones1.uriPrefix(Protocol.pop3) +
"&initialDelay=100&delay=100&ignoreUnsupportedCharset=true")
Review Comment:
Optional: `delete=true` makes each message arrive once, so the test no
longer depends on when the first poll runs:
```suggestion
from(jones1.uriPrefix(Protocol.pop3) +
"&initialDelay=100&delay=100&delete=true&ignoreUnsupportedCharset=true")
```
##########
components/camel-mail/src/test/java/org/apache/camel/component/mail/MailProducerUnsupportedCharsetTest.java:
##########
@@ -46,19 +46,12 @@ public void setupResources() throws Exception {
public void testSendUnsupportedCharset() throws Exception {
jones1.clear();
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() {
- from(jones1.uriPrefix(Protocol.pop3) +
"&initialDelay=100&delay=100&ignoreUnsupportedCharset=true")
- .to("mock:result");
- }
- });
+ // Start context first (needed for template) but without any consumer
route yet.
+ // Both messages must be in the mailbox before the POP3 consumer
starts polling,
+ // otherwise the consumer may pick up only the first message between
the two sends
+ // and the second one is never fetched within the assertion timeout
(flaky test).
Review Comment:
The mechanism is a duplicate rather than a missing message (see the review
body). Suggested wording:
```suggestion
// Start the context first (needed for the template), without the
consumer route yet.
// POP3 has no SEEN flag, so every poll fetches all the messages in
the mailbox again: a poll
// between the two sends delivered Hello World, the next one Hello
World again with Bye World,
// and the mock had its 2 messages with Hello World twice (flaky
test).
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]