6

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 many 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?

  • Do you have the source code? Why not track down the memory leak? ValGrind, et al valgrind.org – Mawg Mar 19 '15 at 8:38
  • The reason for the leak is obvious, but this is a library. I won't change the implementation locally and have currently no time for providing this to the GreenMail project (despite the fact that I'm not even sure if I'd be allowed to do so). – Ray Mar 19 '15 at 11:11
  • 1
    So, 1) you'd rather use something sub-optimal, than make a local fix? And, 2) you are happy enough to use someone's FOSS, but contribute to the community by making others aware of a bug of which you aware? – Mawg Mar 19 '15 at 13:10
  • @Mawg Please don't lecture me on the idea of FOSS, I am well aware of it. I have even opened an issue for this inside GreenMail's github repository, which was basically answered with "Nice idea, can you provide a fix?" Simple answer is: As much as I want to, at this point in time I can't. We use the library for testing purposes in our project, but it's not part of the main deployment, so the leak is basically not important enough in order to allocate resources for fixing it ourselves. That being said, my actual question is still not answered. – Ray Mar 19 '15 at 14:25
  • Glad to hear that you reported it. Ok, let’s see if we can help you ... – Mawg Mar 19 '15 at 15:01
1

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. It's 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 unit tests). 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".

  • Thanks for the suggestion, but it doesn't look like this will provide what I'm looking for. Essentially I want an implementation that will "loose" messages automatically which is what I guess most people exactly don't want. – Ray Mar 13 '15 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.