Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky Test Fix #694

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ private MimeMultipart verifyAndExtractMimeMultipart(String subject)
int expectedEmailCount = 1;
// wait for the server to receive the messages
waitForServerToReceiveEmails(expectedEmailCount);
while (!ch.qos.logback.core.net.SMTPAppenderBase.getExecutionStatus()) {
Thread.yield();
}
MimeMessage[] mma = greenMailServer.getReceivedMessages();
assertNotNull(mma);
assertEquals(expectedEmailCount, mma.length);
Expand Down Expand Up @@ -304,6 +307,7 @@ private void configure(String file) throws JoranException {

@Test
public void testCustomEvaluator() throws Exception {
ch.qos.logback.core.net.SMTPAppenderBase.reset();
startSMTPServer(NO_SSL);
configure(BlackboxClassicTestConstants.JORAN_INPUT_PREFIX + "smtp/customEvaluator.xml");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public abstract class SMTPAppenderBase<E> extends AppenderBase<E> {
protected Layout<E> subjectLayout;
protected Layout<E> layout;

public static volatile boolean hasExecuted;
private List<PatternLayoutBase<E>> toPatternLayoutList = new ArrayList<PatternLayoutBase<E>>();
private String from;
private String subjectStr = null;
Expand Down Expand Up @@ -650,6 +651,14 @@ public void setSessionViaJNDI(boolean sessionViaJNDI) {
this.sessionViaJNDI = sessionViaJNDI;
}

public static boolean getExecutionStatus() {
return hasExecuted;
}

public static void reset() {
hasExecuted = false;
}

/**
* Set the character set encoding of the outgoing email messages. The default
* encoding is "UTF-8" which usually works well for most purposes.
Expand Down Expand Up @@ -680,6 +689,7 @@ class SenderRunnable implements Runnable {

public void run() {
sendBuffer(cyclicBuffer, e);
hasExecuted = true;
}
}
}