Skip to content
Permalink
Browse files
[JENKINS-26452] Tests to reproduce JENKINS-26452.
  • Loading branch information
ikedam committed Jan 17, 2015
1 parent 02e403e commit 2b8793a44f515ed2f3328e2cb4b226f835f4129f
Showing 3 changed files with 70 additions and 0 deletions.
@@ -27,6 +27,7 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import hudson.Launcher;
@@ -53,8 +54,10 @@
import org.jenkins_ci.plugins.run_condition.BuildStepRunner;
import org.jenkins_ci.plugins.run_condition.core.AlwaysRun;
import org.jenkins_ci.plugins.run_condition.core.NeverRun;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.TestExtension;
import org.jvnet.hudson.test.recipes.LocalData;
import org.kohsuke.stapler.DataBoundConstructor;

import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
@@ -469,6 +472,40 @@ public void testNewInstanceDifferFromDataBoundConstructor() throws Exception {
assertEquals(DummyTestDataPublisher.class, archiver.getTestDataPublishers().get(0).getClass());
}

@Bug(26452)
public void testNoPublisher() throws Exception {
FreeStyleProject p = createFreeStyleProject();

p.getPublishersList().add(new FlexiblePublisher(Arrays.asList(
new ConditionalPublisher(
new AlwaysRun(),
Collections.<BuildStep>emptyList(),
new BuildStepRunner.Fail(),
false,
null,
null
)
)));

p.save();

// This doesn't fail till Jenkins 1.500.
reconfigure(p);

assertBuildStatusSuccess(p.scheduleBuild2(0));
assertEquals(0, p.getPublishersList().get(FlexiblePublisher.class).getPublishers().get(0).getPublisherList().size());
}

@Bug(26452)
@LocalData
public void testRecoverFrom26452() throws Exception {
FreeStyleProject p = jenkins.getItemByFullName("affectedBy26452", FreeStyleProject.class);
assertNotNull(p);

assertBuildStatusSuccess(p.scheduleBuild2(0));
assertEquals(0, p.getPublishersList().get(FlexiblePublisher.class).getPublishers().get(0).getPublisherList().size());
}

public static class DummyTestDataPublisher extends TestDataPublisher {
@DataBoundConstructor
public DummyTestDataPublisher() {
@@ -0,0 +1,4 @@
<?xml version='1.0' encoding='UTF-8'?>
<hudson>
<version>1.425</version>
</hudson>
@@ -0,0 +1,29 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders/>
<publishers>
<org.jenkins__ci.plugins.flexible__publish.FlexiblePublisher>
<publishers>
<org.jenkins__ci.plugins.flexible__publish.ConditionalPublisher>
<condition class="org.jenkins_ci.plugins.run_condition.core.AlwaysRun"/>
<publisherList>
<null/>
</publisherList>
<runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Fail"/>
</org.jenkins__ci.plugins.flexible__publish.ConditionalPublisher>
</publishers>
</org.jenkins__ci.plugins.flexible__publish.FlexiblePublisher>
</publishers>
<buildWrappers/>
</project>

0 comments on commit 2b8793a

Please sign in to comment.