X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=tests%2Forg%2Fcacert%2Fgigi%2FtestUtils%2FTestEmailReciever.java;fp=tests%2Forg%2Fcacert%2Fgigi%2FtestUtils%2FTestEmailReciever.java;h=099bbf1a09c7776e8d1760e46bb63023af023a59;hp=dc90acde7ca02bd9f354e17c3fb333c334375732;hb=285506739b7109f16dbff1c24a45e0728e8c1b98;hpb=ec24cf6925bb3729a644580ad4a9375d05883c62 diff --git a/tests/org/cacert/gigi/testUtils/TestEmailReciever.java b/tests/org/cacert/gigi/testUtils/TestEmailReciever.java index dc90acde..099bbf1a 100644 --- a/tests/org/cacert/gigi/testUtils/TestEmailReciever.java +++ b/tests/org/cacert/gigi/testUtils/TestEmailReciever.java @@ -103,11 +103,46 @@ public final class TestEmailReciever extends EmailProvider implements Runnable { LinkedBlockingQueue mails = new LinkedBlockingQueue(); - public TestMail recieve() throws InterruptedException { - TestMail poll = mails.poll(5, TimeUnit.SECONDS); + /** + * Retrieves an outgoing mail from the system. The method will return a + * {@link TestMail} or fail. + * + * @return The intercepted {@link TestMail} + * @see #poll() + */ + public TestMail receive() { + TestMail poll; + + try { + poll = mails.poll(60, TimeUnit.SECONDS); + + } catch (InterruptedException e) { + throw new AssertionError("Interrupted while recieving mails"); + } + if (poll == null) { + throw new AssertionError("Mail recieving timed out"); + } + return poll; } + /** + * Retrieves an outgoing mail from the system or returns null + * if there was no mail sent in 30 seconds. + * + * @return The intercepted {@link TestMail} or null if no mail + * has been sent. + * @see #receive() + */ + public TestMail poll() { + try { + return mails.poll(60, TimeUnit.SECONDS); + + } catch (InterruptedException e) { + throw new AssertionError("Interrupted while recieving mails"); + } + } + @Override public void run() { try {