* intercept the emails. This class resides in the VM that executes the
* testcases and supplies the intercepted emails to the current test case.
*/
-public final class TestEmailReceiver extends EmailProvider implements Runnable {
+public final class TestEmailReceiver extends EmailProvider implements Runnable, MailReceiver {
/**
* An email that has been intercepted.
*/
- public class TestMail {
+ public static class TestMail {
String to;
String message;
- String from;
-
String replyto;
- public TestMail(String to, String subject, String message, String from, String replyto) {
+ public TestMail(String to, String subject, String message, String replyto) {
this.to = to;
this.subject = subject;
this.message = message;
- this.from = from;
this.replyto = replyto;
}
return message;
}
- public String getFrom() {
- return from;
- }
-
public String getReplyto() {
return replyto;
}
}
public void verify() throws IOException {
- String[] parts = extractLink().split("\\?");
+ String link = extractLink();
+ String[] parts = link.split("\\?");
URL u = new URL("https://" + ManagedTest.getServerName() + "/verify?" + parts[1]);
URLConnection csrfConn = u.openConnection();
* @see #destroy()
*/
public void start() {
- new Thread(this, "Mail reciever").start();
+ new Thread(this, "Mail receiver").start();
}
private LinkedBlockingQueue<TestMail> mails = new LinkedBlockingQueue<TestEmailReceiver.TestMail>();
* @return The intercepted {@link TestMail}
* @see #poll()
*/
+ @Override
public TestMail receive() {
TestMail poll;
poll = mails.poll(60, TimeUnit.SECONDS);
} catch (InterruptedException e) {
- throw new AssertionError("Interrupted while recieving mails");
+ throw new AssertionError("Interrupted while receiving mails");
}
if (poll == null) {
- throw new AssertionError("Mail recieving timed out");
+ throw new AssertionError("Mail receiving timed out");
}
return poll;
String to = dis.readUTF();
String subject = dis.readUTF();
String message = dis.readUTF();
- String from = dis.readUTF();
String replyto = dis.readUTF();
- mails.add(new TestMail(to, subject, message, from, replyto));
+ mails.add(new TestMail(to, subject, message, replyto));
} else if (type.equals("challengeAddrBox")) {
String email = dis.readUTF();
dos.writeUTF(quickEmailCheck(email));
/**
* Removes all queued mails.
*/
+ @Override
public void clearMails() {
mails.clear();
}
}
@Override
- public void sendmail(String to, String subject, String message, String from, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
- mails.add(new TestMail(to, subject, message, from, replyto));
+ public void sendMail(String to, String subject, String message, String replyto, String toname, String fromname, String errorsto, boolean extra) throws IOException {
+ mails.add(new TestMail(to, subject, message, replyto));
}
}