提交 7788632a 编写于 作者: K Kohsuke Kawaguchi

Fixed test failures and regressions.

上级 3b5e9f9d
......@@ -719,7 +719,7 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
buildWrappers.rebuild(req, json, BuildWrappers.getFor(this));
builders.rebuildHetero(req, json, Builder.all(), "builder");
publishers.rebuild(req, json, BuildStepDescriptor.filter(Publisher.all(),this.getClass()));
publishers.rebuildHetero(req, json, Publisher.all(), "publisher");
rebuildConfigurations();
}
......
......@@ -200,7 +200,7 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
buildWrappers.rebuild(req,json, BuildWrappers.getFor(this));
builders.rebuildHetero(req,json, Builder.all(), "builder");
publishers.rebuild(req, json, BuildStepDescriptor.filter(Publisher.all(), this.getClass()));
publishers.rebuildHetero(req, json, Publisher.all(), "publisher");
}
@Override
......
......@@ -1042,7 +1042,7 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
processPlugins = req.hasParameter( "maven.processPlugins" );
mavenValidationLevel = NumberUtils.toInt( req.getParameter( "maven.validationLevel" ), -1 );
reporters.rebuild(req,json,MavenReporters.getConfigurableList());
publishers.rebuild(req,json,BuildStepDescriptor.filter(Publisher.all(),this.getClass()));
publishers.rebuildHetero(req, json, Publisher.all(), "publisher");
buildWrappers.rebuild(req,json,BuildWrappers.getFor(this));
settingConfigId = req.getParameter( "maven.mavenSettingsConfigId" );
globalSettingConfigId = req.getParameter( "maven.mavenGlobalSettingConfigId" );
......
......@@ -53,23 +53,19 @@ public class Operation2174Test extends HudsonTestCase {
HtmlForm form = page.getFormByName("config");
// configure downstream build
DescriptorImpl btd = hudson.getDescriptorByType(DescriptorImpl.class);
form.getInputByName(btd.getJsonSafeClassName()).click();
form.getInputByName("buildTrigger.childProjects").setValueAttribute("dp");
submit(form);
up.getPublishersList().add(new BuildTrigger("dp",false));
configRoundtrip(up);
// verify that the relationship is set up
BuildTrigger trigger = up.getPublishersList().get(BuildTrigger.class);
assertEquals(trigger.getChildProjects(), Collections.singletonList(dp));
assertEquals(trigger.getChildProjects(up), Collections.singletonList(dp));
// now go ahead and edit the downstream
page = webClient.getPage(dp,"configure");
form = page.getFormByName("config");
submit(form);
configRoundtrip(dp);
// verify that the relationship is set up
trigger = up.getPublishersList().get(BuildTrigger.class);
assertNotNull(trigger);
assertEquals(trigger.getChildProjects(), Collections.singletonList(dp));
assertEquals(trigger.getChildProjects(up), Collections.singletonList(dp));
}
}
package hudson.model;
import hudson.Functions;
import hudson.tasks.BuildStepMonitor;
import org.jvnet.hudson.test.HudsonTestCase;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
......@@ -33,8 +35,9 @@ public class HelpLinkTest extends HudsonTestCase {
clickAllHelpLinks(createMatrixProject());
}
private void clickAllHelpLinks(Job j) throws Exception {
clickAllHelpLinks(new WebClient().getPage(j,"configure"));
private void clickAllHelpLinks(AbstractProject j) throws Exception {
// TODO: how do we add all the builders and publishers so that we can test this meaningfully?
clickAllHelpLinks(new WebClient().getPage(j, "configure"));
}
private void clickAllHelpLinks(HtmlPage p) throws Exception {
......@@ -46,7 +49,7 @@ public class HelpLinkTest extends HudsonTestCase {
helpLink.click();
}
public static class HelpNotFoundBuilder extends Builder {
public static class HelpNotFoundBuilder extends Publisher {
public static final class DescriptorImpl extends BuildStepDescriptor {
public boolean isApplicable(Class jobType) {
return true;
......@@ -61,6 +64,10 @@ public class HelpLinkTest extends HudsonTestCase {
return "I don't have the help file";
}
}
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.BUILD;
}
}
/**
......@@ -71,7 +78,9 @@ public class HelpLinkTest extends HudsonTestCase {
DescriptorImpl d = new DescriptorImpl();
Publisher.all().add(d);
try {
clickAllHelpLinks(createFreeStyleProject());
FreeStyleProject p = createFreeStyleProject();
p.getPublishersList().add(new HelpNotFoundBuilder());
clickAllHelpLinks(p);
fail("should detect a failure");
} catch(AssertionError e) {
if(e.getMessage().contains(d.getHelpFile()))
......
......@@ -90,11 +90,13 @@ public class MailerTest extends HudsonTestCase {
verifyRoundtrip(m);
}
private void verifyRoundtrip(Mailer m) throws Exception {
private void verifyRoundtrip(Mailer before) throws Exception {
FreeStyleProject p = createFreeStyleProject();
p.getPublishersList().add(m);
p.getPublishersList().add(before);
submit(new WebClient().getPage(p,"configure").getFormByName("config"));
assertEqualBeans(m,p.getPublishersList().get(Mailer.class),"recipients,dontNotifyEveryUnstableBuild,sendToIndividuals");
Mailer after = p.getPublishersList().get(Mailer.class);
assertNotSame(before,after);
assertEqualBeans(before,after,"recipients,dontNotifyEveryUnstableBuild,sendToIndividuals");
}
public void testGlobalConfigRoundtrip() throws Exception {
......
......@@ -24,6 +24,7 @@
package hudson.util;
import hudson.model.FreeStyleProject;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Builder;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
......@@ -43,7 +44,7 @@ public class FormFieldValidatorTest extends HudsonTestCase {
new WebClient().getPage(p,"configure");
}
public static class BrokenFormValidatorBuilder extends Builder {
public static class BrokenFormValidatorBuilder extends Publisher {
public static final class DescriptorImpl extends BuildStepDescriptor {
public boolean isApplicable(Class jobType) {
return true;
......@@ -57,6 +58,10 @@ public class FormFieldValidatorTest extends HudsonTestCase {
return "I have broken form field validation";
}
}
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.BUILD;
}
}
/**
......@@ -68,6 +73,7 @@ public class FormFieldValidatorTest extends HudsonTestCase {
Publisher.all().add(d);
try {
FreeStyleProject p = createFreeStyleProject();
p.getPublishersList().add(new BrokenFormValidatorBuilder());
new WebClient().getPage(p,"configure");
fail("should have failed");
} catch(AssertionError e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册