use of com.icegreen.greenmail.user.GreenMailUser in project gerrit by GerritCodeReview.
the class MailIT method delete.
@Test
public void delete() throws Exception {
GreenMailUser user = mockPop3Server.setUser(USERNAME, USERNAME, PASSWORD);
user.deliver(createSimpleMessage());
assertThat(mockPop3Server.getReceivedMessages().length).isEqualTo(1);
// Let Gerrit handle emails
mailReceiver.handleEmails(false);
// Check that the message is still present
assertThat(mockPop3Server.getReceivedMessages().length).isEqualTo(1);
// Mark the message for deletion
mailReceiver.requestDeletion(mockPop3Server.getReceivedMessages()[0].getMessageID());
// Let Gerrit handle emails
mailReceiver.handleEmails(false);
// Check that the message was deleted
assertThat(mockPop3Server.getReceivedMessages().length).isEqualTo(0);
}
use of com.icegreen.greenmail.user.GreenMailUser 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);
}
}
use of com.icegreen.greenmail.user.GreenMailUser in project gerrit by GerritCodeReview.
the class MailIT method deletesMessageMarkedForDeletion.
@Test
public void deletesMessageMarkedForDeletion() throws Exception {
GreenMailUser user = mockPop3Server.setUser(USERNAME, USERNAME, PASSWORD);
user.deliver(createSimpleMessage());
assertThat(mockPop3Server.getReceivedMessages().length).isEqualTo(1);
// Mark the message for deletion
mailReceiver.requestDeletion(mockPop3Server.getReceivedMessages()[0].getMessageID());
// Let Gerrit handle emails
mailReceiver.handleEmails(false);
// Check that the message was deleted
assertThat(mockPop3Server.getReceivedMessages().length).isEqualTo(0);
}
use of com.icegreen.greenmail.user.GreenMailUser in project gerrit by GerritCodeReview.
the class MailIT method doesNotDeleteMessageNotMarkedForDeletion.
@Test
public void doesNotDeleteMessageNotMarkedForDeletion() throws Exception {
GreenMailUser user = mockPop3Server.setUser(USERNAME, USERNAME, PASSWORD);
user.deliver(createSimpleMessage());
assertThat(mockPop3Server.getReceivedMessages().length).isEqualTo(1);
// Let Gerrit handle emails
mailReceiver.handleEmails(false);
// Check that the message is still present
assertThat(mockPop3Server.getReceivedMessages().length).isEqualTo(1);
}
use of com.icegreen.greenmail.user.GreenMailUser in project sandbox by irof.
the class GreenMailTest method testRetrieving.
@Test
public void testRetrieving() throws Exception {
GreenMailUser user = greenMailRule.setUser("to@example.com", "login-test-id", "login-test-password");
user.deliver(createMessage());
GreenMailUtil.sendTextEmailTest("to@example.com", "from@example.com", "some test subject", "some test body");
assertThat(greenMailRule.getReceivedMessages()).hasSize(2);
}
Aggregations