@@ -0,0 +1,2734 @@
+package org.jenkinsci.plugins.send_mail;%0D%0A%0D%0Aimport static org.hamcrest.CoreMatchers.*;%0D%0Aimport static org.hamcrest.MatcherAssert.*;%0D%0Aimport hudson.model.FreeStyleProject;%0D%0A%0D%0Aimport javax.mail.Address;%0D%0Aimport javax.mail.Message;%0D%0Aimport javax.mail.Message.RecipientType;%0D%0Aimport javax.mail.internet.InternetAddress;%0D%0A%0D%0Aimport jenkins.model.JenkinsLocationConfiguration;%0D%0A%0D%0Aimport org.junit.Rule;%0D%0Aimport org.junit.Test;%0D%0Aimport org.jvnet.hudson.test.JenkinsRule;%0D%0Aimport org.jvnet.mock_javamail.Mailbox;%0D%0A%0D%0Apublic class SendMailBuilderTest %7B%0D%0A%0D%0A    @Rule%0D%0A    public JenkinsRule j = new JenkinsRule();%0D%0A%0D%0A    @Test%0D%0A    public void testConfigurationRoundTrip() throws Exception %7B%0D%0A        final FreeStyleProject p = j.createFreeStyleProject();%0D%0A        final SendMailBuilder before = new SendMailBuilder(%0D%0A                %22tos%22, %22ccs%22, %22bccs%22, %22replyTo%22, %22subject%22, %22text%22);%0D%0A        p.getBuildersList().add(before);%0D%0A        j.submit(j.createWebClient().getPage(p, %22configure%22).getFormByName(%22config%22));%0D%0A        final SendMailBuilder after = p.getBuildersList().get(SendMailBuilder.class);%0D%0A        j.assertEqualBeans(before, after, %22tos,ccs,bccs,replyTo,subject,text%22);%0D%0A    %7D%0D%0A%0D%0A    @Test%0D%0A    public void testMail() throws Exception %7B%0D%0A        final String from = %22from@send-mail-plugin.org%22;%0D%0A        final String to = %22to%22;%0D%0A        final String cc = %22cc%22;%0D%0A        final String bcc = %22bcc%22;%0D%0A        final String replyTo = %22replyTo%22;%0D%0A        final String subject = %22subject%22;%0D%0A        final String text = %22text%22;%0D%0A        final Mailbox inbox = Mailbox.get(new InternetAddress(to));%0D%0A        inbox.clear();%0D%0A        JenkinsLocationConfiguration.get().setAdminAddress(from);%0D%0A        final FreeStyleProject p = j.createFreeStyleProject();%0D%0A        p.getBuildersList().add(new SendMailBuilder(%0D%0A                to, cc, bcc, replyTo, subject, text));%0D%0A        p.scheduleBuild2(0).get();%0D%0A        assertThat(inbox.size(), is(equalTo(1)));%0D%0A        final Message message = inbox.get(0);%0D%0A        verifyAddress(message.getFrom(), from);%0D%0A        verifyAddress(message.getRecipients(RecipientType.TO), to);%0D%0A        verifyAddress(message.getRecipients(RecipientType.CC), cc);%0D%0A        verifyAddress(message.getRecipients(RecipientType.BCC), bcc);%0D%0A        verifyAddress(message.getReplyTo(), replyTo);%0D%0A        assertThat(message.getSubject(), is(equalTo(subject)));%0D%0A        assertThat(message.isMimeType(%22text/plain%22), is(equalTo(true)));%0D%0A        assertThat((String) message.getContent(), is(equalTo(text)));%0D%0A    %7D%0D%0A%0D%0A    private void verifyAddress(final Address%5B%5D actual, final String expected) %7B%0D%0A        assertThat(actual.length, is(equalTo(1)));%0D%0A        assertThat(actual%5B0%5D.toString(), is(equalTo(expected)));%0D%0A    %7D%0D%0A%0D%0A%7D%0D%0A

add testcase