Dumbster Plugin

  • Tags : testing, mail, smtp, smtp-mock
  • Latest : 0.2
  • Last Updated: 21 February 2013
  • Grails version : 2.0 > *
1 vote
Dependency :
compile ":dumbster:0.2"
Custom repositories :
mavenRepo "http://download.java.net/maven/2/"

Documentation Source Issues

Summary

Adds support for the Dumbster SMTP server for testing

Installation

Add a dependency in the plugins section of BuildConfig.groovy:

plugins {
   test ':dumbster:0.1'
   …
}

Description

This plugin adds support for integration testing of sending emails using the Dumbster library.

The plugin creates a "dumbster" Spring bean which starts an SMTP server. You can call the getMessages method to get all sent messages (instances of com.dumbster.smtp.SmtpMessage ) and the getMessageCount to get the number of sent messages. You should add a call to the reset method in your integration test setUp method to clear all previously sent messages between tests.

The SmtpMessage class isn't very easy to work with since you must retrieve most data from header values. It has a getBody method to access the email body though. So the plugin adds some dynamic methods for use in testing:

  • getSubject
  • getDate
  • getTo
  • getTos
  • getCc
  • getCcs
  • getBcc
  • getBccs

Configuration

The plugin will only be active if it is explicitly enabled in Config.groovy, e.g.

test {
   dumbster.enabled = true
}

In addition, you can specify the server port:

test {
   dumbster.enabled = true
   dumbster.port = 1200
}

If you don't specify the port, the plugin will test for open ports starting at 1025 until it finds one it can use. If you have the mail plugin installed this plugin will attempt to update its JavaMailSender (registered as the mailSender bean) with this discovered port.