提交 769aa6ec 编写于 作者: K kohsuke

[HUDSON-1566] added a regression test case for issue 1566.

The point of this test is really more about checking the testability of Hudson, and not so much about actually making sure that issue 1566 won't happen again.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11359 71c3de6d-444a-0410-be80-ed276b4c234a
上级 d9b624bf
package hudson.tasks;
import org.jvnet.hudson.main.HudsonTestCase;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.FailureBuilder;
import org.jvnet.mock_javamail.Mailbox;
import javax.mail.internet.InternetAddress;
import javax.mail.Address;
import hudson.model.FreeStyleProject;
/**
* @author Kohsuke Kawaguchi
*/
public class MailerTest extends HudsonTestCase {
public MailerTest(String name) {
super(name);
}
@Bug(1566)
public void testSenderAddress() throws Exception {
// intentionally give the whole thin in a double quote
Mailer.DESCRIPTOR.setAdminAddress("\"me <me@sun.com>\"");
String recipient = "you <you@sun.com>";
Mailbox yourInbox = Mailbox.get(new InternetAddress(recipient));
yourInbox.clear();
// create a project to simulate a build failure
FreeStyleProject project = (FreeStyleProject)hudson.createProject(FreeStyleProject.DESCRIPTOR, "test" );
project.getBuildersList().add(new FailureBuilder());
Mailer m = new Mailer();
m.recipients = recipient;
project.getPublishersList().add(m);
project.scheduleBuild2(0).get();
assertEquals(1,yourInbox.size());
Address[] senders = yourInbox.get(0).getFrom();
assertEquals(1,senders.length);
assertEquals("me <me@sun.com>",senders[0].toString());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册