Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For testing purposes, our platform can be connected to an email simulator which

ID: 656646 • Letter: F

Question

For testing purposes, our platform can be connected to an email simulator which collects email requests and can be queried to display all received emails. Our current implementation is based on GreenMail. It works basically fine, but when we send maaannnnnnyyyy emails, the simulator will at some point die with an OutOfMemoryError.

We have solved similar issues with our other (self-implemented) simulators (SMS, APNS, GCM) by replacing the simple Lists which were used to store the received messages with Guava's EvictingQueues, so they keep themselves alive even when spammed.

Does anyone know a library out there which we can use to simulate email reception, but that can purge the oldest messages automatically?

Explanation / Answer

Have you tried JavaMail Mock2? I'm not 100% sure if this meets the requirement of purging the oldest email automatically but it looks like it might work for you. Its not a full fledged simulator like what GreenMail is but it does have support for various inboxes. Just to note that I have never tried this before.

From the readme.md:

Open source mock classes for mockup JavaMail (useful especially for unittest). Supports IMAP IDLE.

Features:

Supports imap, imaps, pop3, pop3s, smtp, smtps
POP3
Cast to POP3Folder
Folder.getUID(Message msg)
IMAP
Cast to IMAPFolder and UIDFolder
IDLE
ID
Subfolders
Folder.getMessagesByUID(...)
Delete/rename folders
Append messages
Comes with two modes, normal (halfmock) or fullmock
Normal allows you to connect to real POP or IMAP severs. Generally used if you use mixed testing setups
Fullmock is just for mocked tests only

Here is a link to the java docs and a link to a "real usage scenario".