public void testEmailConfig() throws Exception {
assertTrue( defaultConfigFile.delete() );
assertFalse( defaultConfigFile.exists() );
final EmailResource emailResource = new EmailResource();
final IEmailConfiguration emptyEmailConfig = emailResource.getEmailConfig();
assertTrue( new EmailConfiguration().equals( emptyEmailConfig ) );
// Create an email config to save
assertFalse( defaultConfigFile.exists() );
final EmailConfiguration newEmailConfig = new EmailConfiguration();
newEmailConfig.setSmtpProtocol( "smtp" );
newEmailConfig.setSmtpPort( 35 );
newEmailConfig.setAuthenticate( true );
newEmailConfig.setUserId( "test_user" );
final Response OK_RESPONSE = Response.ok().build();
final Response actual = emailResource.setEmailConfig( newEmailConfig );
assertEquals( OK_RESPONSE.getStatus(), actual.getStatus() );
// Get the email config and compare the values
assertTrue( defaultConfigFile.exists() );
final IEmailConfiguration actualEmailConfig = emailResource.getEmailConfig();
assertTrue( newEmailConfig.equals( actualEmailConfig ) );
// Update the config
newEmailConfig.setSmtpPort( 36 );
newEmailConfig.setUserId( "" );