use of com.icegreen.greenmail.store.StoredMessage in project wso2-axis2-transports by wso2.
the class GreenMailTestEnvironment method allocateAccount.
@Override
public Account allocateAccount() throws Exception {
if (unallocatedAccounts.isEmpty()) {
String login = "test" + accountNumber++;
GreenMailUser user = greenMail.setUser(login + "@localhost", login, "password");
final MailFolder inbox = greenMail.getManagers().getImapHostManager().getInbox(user);
inbox.addListener(new FolderListener() {
public void added(int msn) {
StoredMessage storedMessage = (StoredMessage) inbox.getMessages().get(msn - 1);
try {
OutputStream out = logManager.createLog("greenmail");
try {
storedMessage.getMimeMessage().writeTo(out);
} finally {
out.close();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void expunged(int msn) {
}
public void flagsUpdated(int msn, Flags flags, Long uid) {
}
public void mailboxDeleted() {
}
});
return new Account(user.getEmail(), user.getLogin(), user.getPassword());
} else {
return unallocatedAccounts.remove(0);
}
}
Aggregations