MailContinuumNotifierTest

HomePage | RecentChanges | Preferences

public class MailContinuumNotifierTest
    extends AbstractContinuumTest
{
...
    public void testMultipleNotifiers()
        throws Exception
    {
        Project project = makeStubProject( "Test Project" );
        project.setGroupId( "com.example" );

        BuildResult build = makeBuild( ContinuumProjectState.ERROR );

        MessageContext context = new MessageContext();
        context.setProject( project );
        context.setBuildResult( build );

        List<ProjectNotifier> projectNotifiers = new ArrayList<ProjectNotifier>();

        ProjectNotifier pn1 = new ProjectNotifier();
        pn1.setType( "mail" );
        Map<String, String> config1 = new HashMap<String, String>();
        config1.put( MailContinuumNotifier.ADDRESS_FIELD, "foo@bar" );
        pn1.setConfiguration( config1 );
        projectNotifiers.add( pn1 );

        ProjectNotifier pn2 = new ProjectNotifier();
        pn2.setType( "mail" );
        Map<String, String> config2 = new HashMap<String, String>();
        config2.put( MailContinuumNotifier.ADDRESS_FIELD, "bar@example.com" );
        pn2.setConfiguration( config2 );
        projectNotifiers.add( pn2 );

        context.setNotifier( projectNotifiers );

        Notifier notifier = (Notifier) lookup( Notifier.class.getName(), "mail" );

        ( (MailContinuumNotifier) notifier ).setBuildHost( "foo.bar.com" );

        notifier.sendMessage( ContinuumNotificationDispatcher.MESSAGE_ID_BUILD_COMPLETE, context );

        MockJavaMailSender mailSender = (MockJavaMailSender) lookup( JavaMailSender.class, "continuum" );

        assertEquals( 2, mailSender.getReceivedEmails().size() );

    }

HomePage | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited October 27, 2008 8:58 pm by WendySmoak (diff)
Search: