diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 0bc6c217ff..c1179f0146 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -687,10 +687,9 @@ public abstract class HudsonTestCase extends TestCase { if(pd==null) { // field? try { - Field f1 = lhs.getClass().getField(p); - Field f2 = rhs.getClass().getField(p); - lp = f1.get(lhs); - rp = f2.get(rhs); + Field f = lhs.getClass().getField(p); + lp = f.get(lhs); + rp = f.get(rhs); } catch (NoSuchFieldException e) { assertNotNull("No such property "+p+" on "+lhs.getClass(),pd); return; diff --git a/test/src/test/java/hudson/tasks/MailerTest.java b/test/src/test/java/hudson/tasks/MailerTest.java index 6ffa979f5f..dab6043121 100644 --- a/test/src/test/java/hudson/tasks/MailerTest.java +++ b/test/src/test/java/hudson/tasks/MailerTest.java @@ -27,6 +27,7 @@ import hudson.model.FreeStyleProject; import org.jvnet.hudson.test.Bug; import org.jvnet.hudson.test.FailureBuilder; import org.jvnet.hudson.test.HudsonTestCase; +import org.jvnet.hudson.test.Email; import org.jvnet.mock_javamail.Mailbox; import javax.mail.Address; @@ -72,4 +73,26 @@ public class MailerTest extends HudsonTestCase { url.setValueAttribute("http://localhost:1234/"); assertTrue(p.getDocumentElement().getTextContent().contains("instead of localhost")); } + + @Email("http://www.nabble.com/email-recipients-disappear-from-freestyle-job-config-on-save-to25479293.html") + public void testConfigRoundtrip() throws Exception { + Mailer m = new Mailer(); + m.recipients = "kk@kohsuke.org"; + m.dontNotifyEveryUnstableBuild = true; + m.sendToIndividuals = true; + verifyRoundtrip(m); + + m = new Mailer(); + m.recipients = ""; + m.dontNotifyEveryUnstableBuild = false; + m.sendToIndividuals = false; + verifyRoundtrip(m); + } + + private void verifyRoundtrip(Mailer m) throws Exception { + FreeStyleProject p = createFreeStyleProject(); + p.getPublishersList().add(m); + submit(new WebClient().getPage(p,"configure").getFormByName("config")); + assertEqualBeans(m,p.getPublishersList().get(Mailer.class),"recipients,dontNotifyEveryUnstableBuild,sendToIndividuals"); + } }