Skip to content

Commit

Permalink
[JENKINS-34900] Added a test to reproduce JENKINS-34900. NPE when tri…
Browse files Browse the repository at this point in the history
…ggering single Maven module.
  • Loading branch information
ikedam committed May 21, 2016
1 parent 27f461a commit 6762fc8
Showing 1 changed file with 28 additions and 0 deletions.
Expand Up @@ -7,8 +7,10 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

import org.apache.commons.lang.StringUtils;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.SingleFileSCM;
import org.jvnet.hudson.test.FailureBuilder;
import org.jvnet.hudson.test.SleepBuilder;

Expand All @@ -22,6 +24,7 @@
import hudson.matrix.AxisList;
import hudson.matrix.Combination;
import hudson.matrix.MatrixProject;
import hudson.maven.MavenModuleSet;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
Expand Down Expand Up @@ -383,4 +386,29 @@ public void testVariableForMatrixBuild() throws Exception {
assertEquals("2", maxCountRecorder.getRecordedValue(p.getBuildByNumber(3).getExactRun(new Combination(axisList, "value2"))));
assertEquals("2", buildNumberRecorder.getRecordedValue(p.getBuildByNumber(3).getExactRun(new Combination(axisList, "value2"))));
}

@Bug(34900)
public void testMavenModuleSetWithoutNaginator() throws Exception {
final String SIMPLE_POM = StringUtils.join(new String[]{
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">",
" <modelVersion>4.0.0</modelVersion>",
" <groupId>com.exmaple</groupId>",
" <artifactId>test</artifactId>",
" <version>1.0</version>",
" <packaging>jar</packaging>",
"</project>"
}, "\n");

configureDefaultMaven();
MavenModuleSet p = createMavenProject();
p.setScm(new SingleFileSCM("pom.xml", SIMPLE_POM));
p.setGoals("clean");

// Run once to have the project read the module structure.
assertBuildStatusSuccess(p.scheduleBuild2(0));

// This results MavenModuleBuild#getRootBuild() to be `null`.
assertBuildStatusSuccess(p.getRootModule().scheduleBuild2(0));
}
}

0 comments on commit 6762fc8

Please sign in to comment.